Sfoglia il codice sorgente

Exposed basic app entry URL via codeception.yml, refactored configs of advanced app to read from config and define entry script in a single place

Alexander Makarov 11 anni fa
parent
commit
e7dcdf7c71

+ 4 - 0
tests/codeception.yml

@@ -10,3 +10,7 @@ settings:
     memory_limit: 1024M
     log: true
     colors: true
+config:
+    # the entry script URL (without host info) for functional and acceptance tests
+    # PLEASE ADJUST IT TO THE ACTUAL ENTRY SCRIPT URL
+    test_entry_url: /index-test.php

+ 3 - 11
tests/codeception/_bootstrap.php

@@ -1,21 +1,13 @@
 <?php
-
-// the entry script URL (without host info) for functional and acceptance tests
-// PLEASE ADJUST IT TO THE ACTUAL ENTRY SCRIPT URL
-defined('TEST_ENTRY_URL') or define('TEST_ENTRY_URL', '/index-test.php');
-
-// the entry script file path for functional and acceptance tests
-defined('TEST_ENTRY_FILE') or define('TEST_ENTRY_FILE', dirname(dirname(__DIR__)) . '/web/index-test.php');
-
 defined('YII_DEBUG') or define('YII_DEBUG', true);
-
 defined('YII_ENV') or define('YII_ENV', 'test');
 
-require_once(__DIR__ . '/../../vendor/autoload.php');
+defined('TEST_ENTRY_URL') or define('TEST_ENTRY_URL', \Codeception\Configuration::config()['config']['test_entry_url']);
+defined('TEST_ENTRY_FILE') or define('TEST_ENTRY_FILE', dirname(dirname(__DIR__)) . '/web/index-test.php');
 
+require_once(__DIR__ . '/../../vendor/autoload.php');
 require_once(__DIR__ . '/../../vendor/yiisoft/yii2/Yii.php');
 
-// set correct script paths
 $_SERVER['SCRIPT_FILENAME'] = TEST_ENTRY_FILE;
 $_SERVER['SCRIPT_NAME'] = TEST_ENTRY_URL;
 $_SERVER['SERVER_NAME'] = 'localhost';

+ 0 - 2
tests/codeception/functional/_config.php

@@ -1,6 +1,4 @@
 <?php
-
-// set correct script paths
 $_SERVER['SCRIPT_FILENAME'] = TEST_ENTRY_FILE;
 $_SERVER['SCRIPT_NAME'] = TEST_ENTRY_URL;