Bladeren bron

Fixes #6103: Improved codeception config in app templates to ease testing of advanced app on multiple hosts

Anton Andersen 11 jaren geleden
bovenliggende
commit
6b4ad97e43
3 gewijzigde bestanden met toevoegingen van 8 en 6 verwijderingen
  1. 2 2
      tests/codeception.yml
  2. 3 2
      tests/codeception/_bootstrap.php
  3. 3 2
      tests/codeception/acceptance.suite.yml

+ 2 - 2
tests/codeception.yml

@@ -11,6 +11,6 @@ settings:
     log: true
     colors: true
 config:
-    # the entry script URL (without host info) for functional and acceptance tests
+    # the entry script URL (with host info) for functional and acceptance tests
     # PLEASE ADJUST IT TO THE ACTUAL ENTRY SCRIPT URL
-    test_entry_url: /index-test.php
+    test_entry_url: http://localhost:8080/index-test.php

+ 3 - 2
tests/codeception/_bootstrap.php

@@ -2,7 +2,7 @@
 defined('YII_DEBUG') or define('YII_DEBUG', true);
 defined('YII_ENV') or define('YII_ENV', 'test');
 
-defined('YII_TEST_ENTRY_URL') or define('YII_TEST_ENTRY_URL', \Codeception\Configuration::config()['config']['test_entry_url']);
+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');
 
 require_once(__DIR__ . '/../../vendor/autoload.php');
@@ -10,6 +10,7 @@ require_once(__DIR__ . '/../../vendor/yiisoft/yii2/Yii.php');
 
 $_SERVER['SCRIPT_FILENAME'] = YII_TEST_ENTRY_FILE;
 $_SERVER['SCRIPT_NAME'] = YII_TEST_ENTRY_URL;
-$_SERVER['SERVER_NAME'] = 'localhost';
+$_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__));

+ 3 - 2
tests/codeception/acceptance.suite.yml

@@ -19,8 +19,9 @@ modules:
 #        - WebDriver
     config:
         PhpBrowser:
-            url: 'http://localhost:8080'
+# PLEASE ADJUST IT TO THE ACTUAL ENTRY POINT WITHOUT PATH INFO
+            url: http://localhost:8080
 #        WebDriver:
-#            url: 'http://localhost'
+#            url: http://localhost:8080
 #            browser: firefox
 #            restart: true