Reputation: 735
Currently working on a project for my apprenticeship. I have made some automated tests. I initialised codeception by running and built suite using
codecept bootstrap
codecept build
These 2 commands worked as expected but when I try to run the tests I get
FATAL ERROR. TESTS NOT FINISHED.
Class 'Yii' not found
in /srv/http/blog/vendor/codeception/codeception/src/Codeception/Module/Yii2.php:242
Any got any ideas? I have looked at both Yii's and Codeceptions documentation but cannot find the solution.
UPDATE new error message
FATAL ERROR. TESTS NOT FINISHED.
Class 'Yii' not found
in /srv/http/blog/vendor/yiisoft/yii2/helpers/BaseUrl.php:129
Upvotes: 4
Views: 4664
Reputation: 1855
In my case, the _bootstrap.php
file wouldn't correctly load.
To fix this i've added the following to my codeception.yml
:
settings:
bootstrap: _bootstrap.php
memory_limit: 1024M
colors: true
bootstrap: _bootstrap.php
settings:
memory_limit: 1024M
colors: true
Don't really know what colors does, but it works for me.
Also here is my _bootstrap.php
file for some insights on that as well.
use app\components\Helpers;
define('YII_ENV', 'test');
require_once __DIR__ . '/../vendor/yiisoft/yii2/Yii.php';
require __DIR__ .'/../vendor/autoload.php';
$config = require(__DIR__ . '/../config/console.test.php');
//
$application = new yii\console\Application( $config );
The last two lines are ment to load your Yii class. Hope this will work for u!
From http://phptest.club/t/bootstrap-deprecations-in-3-0/2196
IF you are getting this message:
DEPRECATION: 'settings: bootstrap: _bootstrap.php' option is deprecated! Replace it with: 'bootstrap: _bootstrap.php' (not under settings section). See http://phptest.club/t/bootstrap-deprecations-in-3-0/2196
DEPRECATION: Bootstrap file (_bootstrap.php) is defined in configuration but can't be loaded. Disable 'settings: bootstrap:' configuration to remove this message
Upvotes: 6