That kind of error may appear when running Codeception version 2.4.1 tests in a terminal using Yii2 framework. From a different set of tests on null error may appear in any place with different Yii::$app calls. You may notice that error appears every ~20th test. If you run tests separately one by one all of them will be passed successfully.
The member function may be different:
But in all cases, the error occurs when Yii::$app is called.
The version 2.4.1 introcudes this problem. Version 2.4.0 works fine. The problem was described on April 5 at GitHub issues page #4922 of Codeception. To fix it go to your composer.json file. It is located at your project root folder. Don't touch composer.lock file. It will be updated automatically. Tweak the version of codeception/codeception:
"require-dev": { "yiisoft/yii2-debug": "~2.0.0", "yiisoft/yii2-gii": "~2.0.0", "yiisoft/yii2-faker": "~2.0.0", "codeception/codeception": "2.4.x-dev", "codeception/verify": "~0.3.1" },
You may set version to 2.4.0 or 2.4.x-dev to get the latest version.
Now we need to update codeception/codeception package. Run terminal, go to your project root folder and execute the command:
composer update --prefer-dist
As a result, codeception/codeception package will be updated to fd45d57 commit.
Now problem should be fixed. Let's run tests on the new version of Codeception. Execute this command in the terminal:
php ./vendor/codeception/codeception/codecept run
As you can see the problem was fixed and you can continue with testing using Codeception and Yii framework.
More like this
How to download and use PhpStorm for free legally
Add First Comment. Start a Discussion