-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Closed
Description
I have a problem with Yii2-module.
codeception.yml:
...
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
...
When i start functional test, got the error:
Can't be on page "/index-test.php/about/":
yii\base\ErrorException: array_replace(): Argument #2 is not an array
Scenario Steps:
1. I am on page "/index-test.php/about/"
[yii\base\ErrorException] array_replace(): Argument #2 is not an array
#1 yii\base\ErrorHandler->handleError
#2 /root/.composer/vendor/symfony/browser-kit/CookieJar.php:210
#3 /root/.composer/vendor/symfony/browser-kit/Client.php:316
#4 Codeception\Module\Yii2->amOnPage
#5 /usr/local/www/website/www/tests/front/codeception/functional/FunctionalTester.php:484
#6 /usr/local/www/website/www/vendor/yiisoft/yii2-codeception/BasePage.php:77
#7 /usr/local/www/website/www/tests/front/codeception/functional/AboutCept.php:7
#8 Codeception\TestCase\Cept->testCodecept
Error raise when HTTP_HOST is empty on /root/.composer/vendor/symfony/browser-kit/Client.php
/vendor/codeception/codeception/src/Codeception/Module/Yii2.php:22 force set empty HTTP_HOST when parse from test_entry_url. Next vendor/symfony/browser-kit/Client.php:113 merge empty HTTP_HOST with their server - vars. And finaly got error when parse_url return not array on vendor/symfony/browser-kit/CookieJar.php:210
My solve, set HTTP_HOST to 'localhost', when it empty on vendor/codeception/codeception/src/Codeception/Module/Yii2.php:
public function _before(\Codeception\TestCase $test)
{
$this->client = new \Codeception\Lib\Connector\Yii2();
$this->client->configFile = \Codeception\Configuration::projectDir().$this->config['configFile'];
$mainConfig = \Codeception\Configuration::config();
if (isset($mainConfig['config']) && isset($mainConfig['config']['test_entry_url'])){
$this->client->setServerParameter('HTTP_HOST', (string) parse_url($mainConfig['config']['test_entry_url'], PHP_URL_HOST));
$this->client->setServerParameter('HTTPS', ((string) parse_url($mainConfig['config']['test_entry_url'], PHP_URL_SCHEME)) === 'https');
}
$this->app = $this->client->startApp();
if ($this->config['cleanup'] and isset($this->app->db)) {
$this->transaction = $this->app->db->beginTransaction();
}
}
to
public function _before(\Codeception\TestCase $test)
{
$this->client = new \Codeception\Lib\Connector\Yii2();
$this->client->configFile = \Codeception\Configuration::projectDir().$this->config['configFile'];
$mainConfig = \Codeception\Configuration::config();
if (isset($mainConfig['config']) && isset($mainConfig['config']['test_entry_url'])){
$host = (string) parse_url($mainConfig['config']['test_entry_url'], PHP_URL_HOST);
$this->client->setServerParameter('HTTP_HOST', strlen($host) ? $host : 'localhost');
$this->client->setServerParameter('HTTPS', ((string) parse_url($mainConfig['config']['test_entry_url'], PHP_URL_SCHEME)) === 'https');
}
$this->app = $this->client->startApp();
if ($this->config['cleanup'] and isset($this->app->db)) {
$this->transaction = $this->app->db->beginTransaction();
}
}
Metadata
Metadata
Assignees
Labels
No labels