Skip to content

Commit 4e657a2

Browse files
NaktibaldaGintautas Miselis
authored andcommitted
Fixed broken tests
Symfony/browser-kit now makes requests to host specified in Host header So it is no longer possible to test Host header by making requests to localhost
1 parent 6e8c9f3 commit 4e657a2

File tree

2 files changed

+15
-33
lines changed

2 files changed

+15
-33
lines changed

tests/data/rest/index.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,11 @@
2929
],
3030
];
3131
},
32-
'http-host' => function() {
33-
return 'host: "' . $_SERVER['HTTP_HOST'] . '"';
32+
'foo' => function() {
33+
if (isset($_SERVER['HTTP_FOO'])) {
34+
return 'foo: "' . $_SERVER['HTTP_FOO'] . '"';
35+
}
36+
return 'foo: not found';
3437
}
3538

3639
];

tests/unit/Codeception/Module/PhpBrowserRestTest.php

Lines changed: 10 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -271,46 +271,25 @@ public function testCanInspectResultOfPhpBrowserRequest()
271271
$this->module->seeResponseIsJson();
272272
}
273273

274-
/**
275-
* @Issue https://github.com/Codeception/Codeception/issues/1650
276-
*/
277-
public function testHostHeader()
278-
{
279-
if (getenv('dependencies') === 'lowest') {
280-
$this->markTestSkipped('This test can\'t pass with the lowest versions of dependencies');
281-
}
282-
283-
$this->module->sendGET('/rest/http-host/');
284-
$this->module->seeResponseContains('host: "localhost:8010"');
285-
286-
$this->module->haveHttpHeader('Host', 'www.example.com');
287-
$this->module->sendGET('/rest/http-host/');
288-
$this->module->seeResponseContains('host: "www.example.com"');
289-
}
290-
291274
/**
292275
* @Issue 4203 https://github.com/Codeception/Codeception/issues/4203
293-
* @depends testHostHeader
294276
*/
295277
public function testSessionHeaderBackup()
296278
{
297-
if (getenv('dependencies') === 'lowest') {
298-
$this->markTestSkipped('This test can\'t pass with the lowest versions of dependencies');
299-
}
300279

301-
$this->module->haveHttpHeader('Host', 'www.example.com');
302-
$this->module->sendGET('/rest/http-host/');
303-
$this->module->seeResponseContains('host: "www.example.com"');
280+
$this->module->haveHttpHeader('foo', 'bar');
281+
$this->module->sendGET('/rest/foo/');
282+
$this->module->seeResponseContains('foo: "bar"');
304283

305284
$session = $this->phpBrowser->_backupSession();
306285

307-
$this->module->haveHttpHeader('Host', 'www.localhost.com');
308-
$this->module->sendGET('/rest/http-host/');
309-
$this->module->seeResponseContains('host: "www.localhost.com"');
286+
$this->module->haveHttpHeader('foo', 'baz');
287+
$this->module->sendGET('/rest/foo/');
288+
$this->module->seeResponseContains('foo: "baz"');
310289

311290
$this->phpBrowser->_loadSession($session);
312-
$this->module->sendGET('/rest/http-host/');
313-
$this->module->seeResponseContains('host: "www.example.com"');
291+
$this->module->sendGET('/rest/foo/');
292+
$this->module->seeResponseContains('foo: "bar"');
314293
}
315294

316295
protected function shouldFail()
@@ -320,7 +299,7 @@ protected function shouldFail()
320299

321300
public function testGrabFromCurrentUrl()
322301
{
323-
$this->module->sendGET('/rest/http-host/');
324-
$this->assertEquals('/rest/http-host/', $this->phpBrowser->grabFromCurrentUrl());
302+
$this->module->sendGET('/rest/foo/');
303+
$this->assertEquals('/rest/foo/', $this->phpBrowser->grabFromCurrentUrl());
325304
}
326305
}

0 commit comments

Comments
 (0)