Skip to content

Commit fd52a3f

Browse files
Fix tests (bis)
1 parent de1e859 commit fd52a3f

File tree

3 files changed

+15
-9
lines changed

3 files changed

+15
-9
lines changed

HttpClient/Test/Fixtures/web/index.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
}
3131

3232
$json = json_encode($vars, \JSON_PRETTY_PRINT | \JSON_UNESCAPED_SLASHES | \JSON_UNESCAPED_UNICODE);
33+
$localhost = gethostbyname('localhost');
3334

3435
switch ($vars['REQUEST_URI']) {
3536
default:
@@ -41,7 +42,7 @@
4142

4243
case '/':
4344
case '/?a=a&b=b':
44-
case 'http://127.0.0.1:8057/':
45+
case "http://$localhost:8057/":
4546
case 'http://localhost:8057/':
4647
ob_start('ob_gzhandler');
4748
break;
@@ -74,7 +75,7 @@
7475

7576
case '/301':
7677
if ('Basic Zm9vOmJhcg==' === $vars['HTTP_AUTHORIZATION']) {
77-
header('Location: http://127.0.0.1:8057/302', true, 301);
78+
header("Location: http://$localhost:8057/302", true, 301);
7879
}
7980
break;
8081

HttpClient/Test/HttpClientTestCase.php

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -335,6 +335,7 @@ public function test304()
335335
public function testRedirects()
336336
{
337337
$client = $this->getHttpClient(__FUNCTION__);
338+
$localhost = gethostbyname('localhost');
338339
$response = $client->request('POST', 'http://localhost:8057/301', [
339340
'auth_basic' => 'foo:bar',
340341
'body' => function () {
@@ -352,7 +353,7 @@ public function testRedirects()
352353

353354
$expected = [
354355
'HTTP/1.1 301 Moved Permanently',
355-
'Location: http://127.0.0.1:8057/302',
356+
"Location: http://$localhost:8057/302",
356357
'Content-Type: application/json',
357358
'HTTP/1.1 302 Found',
358359
'Location: http://localhost:8057/',
@@ -425,6 +426,7 @@ public function testRedirect307()
425426
public function testMaxRedirects()
426427
{
427428
$client = $this->getHttpClient(__FUNCTION__);
429+
$localhost = gethostbyname('localhost');
428430
$response = $client->request('GET', 'http://localhost:8057/301', [
429431
'max_redirects' => 1,
430432
'auth_basic' => 'foo:bar',
@@ -442,7 +444,7 @@ public function testMaxRedirects()
442444

443445
$expected = [
444446
'HTTP/1.1 301 Moved Permanently',
445-
'Location: http://127.0.0.1:8057/302',
447+
"Location: http://$localhost:8057/302",
446448
'Content-Type: application/json',
447449
'HTTP/1.1 302 Found',
448450
'Location: http://localhost:8057/',
@@ -691,8 +693,9 @@ public function testOnProgressError()
691693
public function testResolve()
692694
{
693695
$client = $this->getHttpClient(__FUNCTION__);
696+
$localhost = gethostbyname('localhost');
694697
$response = $client->request('GET', 'http://symfony.com:8057/', [
695-
'resolve' => ['symfony.com' => '127.0.0.1'],
698+
'resolve' => ['symfony.com' => $localhost],
696699
]);
697700

698701
$this->assertSame(200, $response->getStatusCode());
@@ -706,15 +709,16 @@ public function testResolve()
706709
public function testIdnResolve()
707710
{
708711
$client = $this->getHttpClient(__FUNCTION__);
712+
$localhost = gethostbyname('localhost');
709713

710714
$response = $client->request('GET', 'http://0-------------------------------------------------------------0.com:8057/', [
711-
'resolve' => ['0-------------------------------------------------------------0.com' => '127.0.0.1'],
715+
'resolve' => ['0-------------------------------------------------------------0.com' => $localhost],
712716
]);
713717

714718
$this->assertSame(200, $response->getStatusCode());
715719

716720
$response = $client->request('GET', 'http://Bücher.example:8057/', [
717-
'resolve' => ['xn--bcher-kva.example' => '127.0.0.1'],
721+
'resolve' => ['xn--bcher-kva.example' => $localhost],
718722
]);
719723

720724
$this->assertSame(200, $response->getStatusCode());

HttpClient/Test/TestHttpServer.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,15 +31,16 @@ public static function start(int $port = 8057)
3131
});
3232
}
3333

34+
$localhost = gethostbyname('localhost');
3435
$finder = new PhpExecutableFinder();
35-
$process = new Process(array_merge([$finder->find(false)], $finder->findArguments(), ['-dopcache.enable=0', '-dvariables_order=EGPCS', '-S', '127.0.0.1:'.$port]));
36+
$process = new Process(array_merge([$finder->find(false)], $finder->findArguments(), ['-dopcache.enable=0', '-dvariables_order=EGPCS', '-S', "$localhost:$port"]));
3637
$process->setWorkingDirectory(__DIR__.'/Fixtures/web');
3738
$process->start();
3839
self::$process[$port] = $process;
3940

4041
do {
4142
usleep(50000);
42-
} while (!@fopen('http://127.0.0.1:'.$port, 'r'));
43+
} while (!@fopen("http://$localhost:$port", 'r'));
4344

4445
return $process;
4546
}

0 commit comments

Comments
 (0)