Answer the question
In order to leave comments, you need to log in
How to bypass dependency on yii\web\Request in unit test?
Application based on basic. The dragonjet\opengraph\OpenGraph component is used.
Trying to run standard tests, started with unit. The first error:
1) tests\codeception\unit\models\ContactFormTest::testContact
yii\base\InvalidConfigException: Unable to determine the request URI.
#1 C:\dev\OpenServer524\domains\mysite\vendor\yiisoft\yii2\web\Request.php:769
Answer the question
In order to leave comments, you need to log in
You can try running the unit through phpunit rather than through CodeCeption.
some necroposting
config
paths:
tests: tests
output: tests/_output
data: tests/_data
support: tests/_support
envs: tests/_envs
actor_suffix: Tester
settings:
bootstrap: _bootstrap.php
colors: false
memory_limit: 1024M
extensions:
enabled:
- Codeception\Extension\RunFailed
# Codeception Test Suite Configuration
#
# Suite for unit or integration tests.
class_name: UnitTester
modules:
enabled:
- Asserts
- Yii2:
part: [orm, fixtures, email]
configFile: 'tests/_config/unit.php'
\yii\helpers\FileHelper::createDirectory(\Yii::getAlias('@tests/_output/assets'));
return [
'id' => 'test-console',
'class' => 'yii\web\Application',
'basePath' => \Yii::getAlias('@tests'),
'runtimePath' => \Yii::getAlias('@tests/_output'),
'components' => [
'request' => [
'cookieValidationKey' => 'wefJDF8s',
'scriptFile' => \Yii::getAlias('@tests/_output/index.php'),
'url' => '/', # задаем и ошибки не будет
'scriptUrl' => '/index.php',
],
'assetManager' => [
'bundles' => [
// отрубаем публикацию ассетов
'yii\grid\GridViewAsset' => false,
'yii\web\JqueryAsset' => false,
],
],
],
];
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question