I am trying to run my functional test and this is the error message i get
[PHPUnit_Framework_Exception] Undefined index: config in C:\wamp\www\test.qsims.com\tests\functional_bootstrap.php on line 4**
I'm trying to parse URL in the functional/_bootstrap.php file. The code for the following is below
<?php
define('DS', DIRECTORY_SEPARATOR);
defined('YII_TEST_ENTRY_URL') or define('YII_TEST_ENTRY_URL', parse_url(\Codeception\Configuration::config()['config']['test_entry_url'], PHP_URL_PATH));
defined('YII_TEST_ENTRY_FILE') or define('YII_TEST_ENTRY_FILE', dirname(dirname(__DIR__)) . '/web/index-test.php');
// Define our application_env variable as provided by nginx/apache
if (!defined('APPLICATION_ENV'))
{
if (getenv('APPLICATION_ENV') != false)
define('APPLICATION_ENV', getenv('APPLICATION_ENV'));
else
define('APPLICATION_ENV', 'dev');
}
$env = require(__DIR__ . '/../../config/env.php');
// comment out the following two lines when deployed to production
defined('YII_DEBUG') or define('YII_DEBUG', $env['debug']);
defined('YII_ENV') or define('YII_ENV', APPLICATION_ENV);
require(__DIR__ . '/../../vendor/autoload.php');
require(__DIR__ . '/../../vendor/yiisoft/yii2/Yii.php');
$config = require(__DIR__ . '/../../config/web.php');
$_SERVER['SCRIPT_FILENAME'] = YII_TEST_ENTRY_FILE;
$_SERVER['SCRIPT_NAME'] = YII_TEST_ENTRY_URL;
$_SERVER['SERVER_NAME'] = parse_url(\Codeception\Configuration::config()['config']['test_entry_url'], PHP_URL_HOST);
$_SERVER['SERVER_PORT'] = parse_url(\Codeception\Configuration::config()['config']['test_entry_url'], PHP_URL_PORT) ?: '80';
Yii::setAlias('@tests', dirname(__DIR__));
(new yii\web\Application($config));
When I run my $ ./vendor/bin/codecept run. I get the above error.
So the parse_url line i.e. the 4th line is breaking the code. Can anyone help me out in this, trying to solve it from past 6 hrs or so.. Thanks in advance
Codeception.yml
actor: Tester
#coverage:
# #c3_url: http://localhost:8080/index-test.php/
# enabled: true
# #remote: true
# #remote_config: '../tests/codeception.yml'
# white_list:
# include:
# - ../models/*
# - ../controllers/*
# - ../commands/*
# - ../mail/*
# blacklist:
# include:
# - ../assets/*
# - ../config/*
# - ../runtime/*
# - ../vendor/*
# - ../views/*
# - ../web/*
# - ../tests/*
paths:
tests: codeception
log: codeception/_output
data: codeception/_data
helpers: codeception/_support
settings:
bootstrap: _bootstrap.php
suite_class: \PHPUnit_Framework_TestSuite
memory_limit: 1024M
log: true
colors: 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/index-test.php
functional.suite.yml
class_name: FunctionalTester
modules:
enabled:
- Filesystem
- Yii2
config:
Yii2:
configFile: 'codeception/config/functional.php'
defined('YII_TEST_ENTRY_URL') or define('YII_TEST_ENTRY_URL', parse_url(\Codeception\Configuration::config()['config']['test_entry_url'], PHP_URL_PATH));
Change the above line to the code mentioned below
defined('YII_TEST_ENTRY_URL') or define('YII_TEST_ENTRY_URL', 'http://test.qsims.com/web/index-test.php');
For some reason it was not retrieving my url form codeception.yml form so I have hardcorded the url in the place of parse_url(\Codeception\Configuration::config()['config']['test_entry_url'], PHP_URL_PATH))
to actual url :'http://test.qsims.com/web/index-test.php'