Skip to content

Commit 9618aa0

Browse files
Merge branch '4.4' into 5.2
* 4.4: fix tests (quinter)
2 parents 964241a + d89f292 commit 9618aa0

File tree

3 files changed

+10
-16
lines changed

3 files changed

+10
-16
lines changed

HttpClient/Test/Fixtures/web/index.php

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

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

3534
switch ($vars['REQUEST_URI']) {
3635
default:
@@ -42,7 +41,7 @@
4241

4342
case '/':
4443
case '/?a=a&b=b':
45-
case "http://$localhost:8057/":
44+
case 'http://127.0.0.1:8057/':
4645
case 'http://localhost:8057/':
4746
ob_start('ob_gzhandler');
4847
break;
@@ -75,7 +74,7 @@
7574

7675
case '/301':
7776
if ('Basic Zm9vOmJhcg==' === $vars['HTTP_AUTHORIZATION']) {
78-
header("Location: http://$localhost:8057/302", true, 301);
77+
header('Location: http://127.0.0.1:8057/302', true, 301);
7978
}
8079
break;
8180

HttpClient/Test/HttpClientTestCase.php

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -334,7 +334,6 @@ public function test304()
334334
public function testRedirects()
335335
{
336336
$client = $this->getHttpClient(__FUNCTION__);
337-
$localhost = gethostbyname('localhost');
338337
$response = $client->request('POST', 'http://localhost:8057/301', [
339338
'auth_basic' => 'foo:bar',
340339
'body' => function () {
@@ -352,7 +351,7 @@ public function testRedirects()
352351

353352
$expected = [
354353
'HTTP/1.1 301 Moved Permanently',
355-
"Location: http://$localhost:8057/302",
354+
'Location: http://127.0.0.1:8057/302',
356355
'Content-Type: application/json',
357356
'HTTP/1.1 302 Found',
358357
'Location: http://localhost:8057/',
@@ -425,7 +424,6 @@ public function testRedirect307()
425424
public function testMaxRedirects()
426425
{
427426
$client = $this->getHttpClient(__FUNCTION__);
428-
$localhost = gethostbyname('localhost');
429427
$response = $client->request('GET', 'http://localhost:8057/301', [
430428
'max_redirects' => 1,
431429
'auth_basic' => 'foo:bar',
@@ -443,7 +441,7 @@ public function testMaxRedirects()
443441

444442
$expected = [
445443
'HTTP/1.1 301 Moved Permanently',
446-
"Location: http://$localhost:8057/302",
444+
'Location: http://127.0.0.1:8057/302',
447445
'Content-Type: application/json',
448446
'HTTP/1.1 302 Found',
449447
'Location: http://localhost:8057/',
@@ -692,9 +690,8 @@ public function testOnProgressError()
692690
public function testResolve()
693691
{
694692
$client = $this->getHttpClient(__FUNCTION__);
695-
$localhost = gethostbyname('localhost');
696693
$response = $client->request('GET', 'http://symfony.com:8057/', [
697-
'resolve' => ['symfony.com' => $localhost],
694+
'resolve' => ['symfony.com' => '127.0.0.1'],
698695
]);
699696

700697
$this->assertSame(200, $response->getStatusCode());
@@ -708,16 +705,15 @@ public function testResolve()
708705
public function testIdnResolve()
709706
{
710707
$client = $this->getHttpClient(__FUNCTION__);
711-
$localhost = gethostbyname('localhost');
712708

713709
$response = $client->request('GET', 'http://0-------------------------------------------------------------0.com:8057/', [
714-
'resolve' => ['0-------------------------------------------------------------0.com' => $localhost],
710+
'resolve' => ['0-------------------------------------------------------------0.com' => '127.0.0.1'],
715711
]);
716712

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

719715
$response = $client->request('GET', 'http://Bücher.example:8057/', [
720-
'resolve' => ['xn--bcher-kva.example' => $localhost],
716+
'resolve' => ['xn--bcher-kva.example' => '127.0.0.1'],
721717
]);
722718

723719
$this->assertSame(200, $response->getStatusCode());
@@ -885,7 +881,7 @@ public function testProxy()
885881

886882
$body = $response->toArray();
887883
$this->assertSame('localhost:8057', $body['HTTP_HOST']);
888-
$this->assertMatchesRegularExpression('#^http://(localhost|127\.0\.\d+\.1):8057/$#', $body['REQUEST_URI']);
884+
$this->assertMatchesRegularExpression('#^http://(localhost|127\.0\.0\.1):8057/$#', $body['REQUEST_URI']);
889885

890886
$response = $client->request('GET', 'http://localhost:8057/', [
891887
'proxy' => 'http://foo:b%3Dar@localhost:8057',

HttpClient/Test/TestHttpServer.php

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

31-
$localhost = gethostbyname('localhost');
3231
$finder = new PhpExecutableFinder();
33-
$process = new Process(array_merge([$finder->find(false)], $finder->findArguments(), ['-dopcache.enable=0', '-dvariables_order=EGPCS', '-S', "$localhost:$port"]));
32+
$process = new Process(array_merge([$finder->find(false)], $finder->findArguments(), ['-dopcache.enable=0', '-dvariables_order=EGPCS', '-S', '127.0.0.1:'.$port]));
3433
$process->setWorkingDirectory(__DIR__.'/Fixtures/web');
3534
$process->start();
3635
self::$process[$port] = $process;
3736

3837
do {
3938
usleep(50000);
40-
} while (!@fopen("http://$localhost:$port", 'r'));
39+
} while (!@fopen('http://127.0.0.1:'.$port, 'r'));
4140

4241
return $process;
4342
}

0 commit comments

Comments
 (0)