Answer the question
In order to leave comments, you need to log in
How to run codecaption unit tests on yii2 advanced?
Hello. I want to run unit tests but it doesn't work, it
gives this error:
[yii\base\InvalidConfigException]
The "id" configuration for the Application is required.
frontend/config.php
return [
'language' => 'en-US',
'components' => [
'db' => [
'dsn' => 'mysql:host=localhost;dbname=mytest',
'username' => 'root',
'password' => '',
],
'mailer' => [
'useFileTransport' => true,
],
'urlManager' => [
'showScriptName' => true,
],
],
];
frontend\unit\_bootstrap.php
:$application = new yii\web\Application(__DIR__. '/../../config/frontend/unit.php');
frontend\codeception.yml
:namespace: tests\codeception\frontend
actor: Tester
paths:
tests: .
log: _output
data: _data
helpers: _support
settings:
bootstrap: _bootstrap.php
suite_class: \PHPUnit_Framework_TestSuite
colors: true
memory_limit: 1024M
log: true
config:
# the entry script URL (with host info) for functional and acceptance tests
# PLEASE ADJUST IT TO THE ACTUAL ENTRY SCRIPT URL
test_entry_url: http://localhost:8080/frontend/web/index-test.php
modules:
config:
Db:
dsn: 'mysql:host=localhost;dbname=mytest'
user: 'root'
password: ''
frontend\unit.suite.yml
:class_name: WebGuy
modules:
enabled:
- Db
codecept run unit
from the folder tests\codeception\frontend
Answer the question
In order to leave comments, you need to log in
well, in this case, your error clearly says that the application identifier is not set in the config, which is required for work
I solved the error by adding the id parameter to the config/frontend/config/unit.php
return yii\helpers\ArrayHelper::merge(
require(YII_APP_BASE_PATH . '/common/config/main.php'),
require(YII_APP_BASE_PATH . '/common/config/main-local.php'),
require(YII_APP_BASE_PATH . '/frontend/config/main.php'),
require(YII_APP_BASE_PATH . '/frontend/config/main-local.php'),
require(dirname(__DIR__) . '/config.php'),
require(dirname(__DIR__) . '/config-local.php'),
require(dirname(__DIR__) . '/unit.php'),
require(__DIR__ . '/config.php'),
[
'id' => 'app-frontend',
'basePath' => dirname(__DIR__),
]
);
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question