mercredi 22 juin 2016

function test, Notice: Undefined index: config

I am trying to run my functional test and this is the error message i get

Notice: 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 4 th 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

Aucun commentaire:

Enregistrer un commentaire