I am using codeception 2.2.5 aand Yii 1.1.4 I have the issue with the Yii1 module. I have it configured for functional and unit tests
Here is the functional.suite.yml
class_name: FunctionalTester
modules:
enabled:
- Yii1:
appPath: 'www/test.php'
url: 'http://localhost/test.php'
part: init
- PhpBrowser:
url: 'http://localhost/index-test.php'
- \Helper\Functional
coverage:
enabled: true
remote: false
Here is the unit.suite.yml
class_name: UnitTester
modules:
enabled:
- Asserts
- Yii1:
appPath: 'www/test.php'
url: 'http://localhost/test.php'
- \Helper\Unit
When I run the tests separately everything works great. e.g.
php codecept.phar run functional --xml --html
php codecept.phar run unit --xml --html
When I run all together
php codecept.phar run --xml --html
It runs the functional without the issue connected with the Yii1 module. And on the unit it brings
[Codeception\Exception\ModuleConfigException]
Yii1 module is not configured!
Couldn't load application config file www/test.php
Please provide application bootstrap file configured for testing
The main goal to run all together is the code coverage.
Here is the answer to my problem:
I created a separate module Yii1Ext(Yii1Ext.php) which extends to Yii1 module:
namespace Helper;
use Codeception\Module\Yii1;
class Yii1Ext extends Yii1
{
public function _initialize()
{
$this->config['appPath'] = FRONTEND.'/'.$this->config['appPath'];
parent::_initialize();
}
}
And in configuration files have the Yii1Ext module enabled instead of Yii1 module
class_name: FunctionalTester
modules:
enabled:
- \Helper\Yii1Ext:
appPath: 'www/test.php'
url: 'http://localhost/test.php'
part: init
- PhpBrowser:
url: 'http://localhost/'
Note: Make sure all defined variables in Yii are defined by the statement
defined('ROOT_DIR') or define('ROOT_DIR', realpath(__DIR__ . '/../'));