Is it possible to store Functional/Acceptance config URL of Codeception outside repository?

大憨熊 提交于 2019-12-01 22:13:00

One way to solve this is to look at the $_SERVER['HOSTNAME'] value and select the appropriate url from that. I've currently got this in my tests/acceptance/_bootstrap.php

switch($_SERVER['HOSTNAME'])
{
  case 'dev1':
    $base_url = 'http://www.example.com.dev1';
    break;
  default:
    $base_url = 'http://www.example.com';
    break;
}
define("BASE_URL",$base_url);

You can then make use of this constant in a test

$I = new AcceptanceTester($scenario);
$I->wantTo('ensure that the a user can log in');
$I->amOnUrl(BASE_URL . "/home");
Didin Ahmadi

I have same problem. I asked same question here. I used --environment option to get this working.

here is the example configuration:

class_name: FunctionalTester
modules:
    enabled:
        # add framework module here
        - Yii1
        - \Helper\Functional
        - PhpBrowser
        - Db
    config:
        Yii1:
            appPath: '/Volumes/disk0s4/www/new-proj/trunk/test.php'
            url: 'https://my.proj.local/test.php'
        PhpBrowser:
            url: 'https://my.proj.didin/'
        Db:
            dsn: 'mysql:host=127.0.0.1;dbname=test-proj-new'
            user: 'root'
            password: 'root'
env:
    my_env:
       modules:
            enabled:
                - Yii1
                - \Helper\Functional
            config:
                Yii1:
                     appPath: 'path to index.php of my environment'
                     url: 'http://my.local/test.php'
    production_env:
       modules:
            enabled:
                - Yii1
                - \Helper\Functional
            config:
                Yii1:
                     appPath: 'path to index.php of production environment'
                     url: 'http://my.local.com/test.php'

I know that config contains duplicated-lines and should be able to be simplified, I've tried to simplify by removing duplicate line at global modules, but seems doesn't work to me.

So I let the config as you see above and I have created Issue for it, but still wondering if someone get this overriding working.

I hope this helps to anyone.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!