static function writeCodeceptionConfig() { // codeception.yml write db parameters $baseFolder = TestConfig::getConfig('testRunnerPath'); // load template $yaml = file_get_contents($baseFolder . DS . 'codeception.template.yml'); $data = Yaml::parse($yaml); // ensure structure in template array if (is_array($data)) { //if (!array_key_exists('modules',$data)) $data['modules']=array(); //if (!array_key_exists('enabled',$data['modules'])) $data['modules']['enabled']=array(); //if (!array_key_exists('Db',$data['modules']['enabled'])) $data['modules']['enabled']['Db']=array(); // set db connection details $portNumber = TestConfig::getConfig('port'); $port = isset($portNumber) && !empty($portNumber) ? ";port=" . $portNumber : ""; $url = TestConfig::getConfig('driver') . ":host=" . TestConfig::getConfig('confighostname') . ";dbname=" . TestConfig::getConfig('database') . $port; //$data['coverage']['include']=[$url]; //$data['coverage']['exclude']=[$url]; $data['modules']['config']['Db']['dsn'] = $url; $data['modules']['config']['Db']['user'] = strlen(trim(TestConfig::getConfig('username'))) > 0 ? TestConfig::getConfig('username') : ''; $data['modules']['config']['Db']['password'] = strlen(trim(TestConfig::getConfig('password'))) > 0 ? TestConfig::getConfig('password') : ''; // disable phantom for unit tests if (TestConfig::getConfig('testSuite') === 'unit') { unset($data['extensions']['enabled'][array_search('Codeception\\Extension\\Phantoman', $data['extensions']['enabled'])]); } else { $data['extensions']['config']['Codeception\\Extension\\Phantoman']['path'] = TestConfig::getConfig('phantomjs'); } // enable coverage if (TestConfig::getConfig('coverage') && TestConfig::getConfig('cmFivePath') && is_dir(TestConfig::getConfig('cmFivePath'))) { $relativePath = FileSystemTools::findRelativePath(realpath(TestConfig::getConfig('testStagingPath')), realpath(TestConfig::getConfig('cmFivePath'))); $data['coverage'] = ['enabled' => 'true', 'remote' => 'false', 'include' => [$relativePath . '\\system\\web*.php', $relativePath . '\\system\\functions*.php', $relativePath . '\\system\\html*.php', $relativePath . '\\system\\classes\\*', $relativePath . '\\system\\modules\\*', $relativePath . '\\modules\\*'], 'exclude' => ['\\*']]; } $yaml = Yaml::dump($data); } $codeceptionFile = TestConfig::getConfig('testStagingPath') . DS . 'codeception.yml'; file_put_contents($codeceptionFile, $yaml); }