8000 fix tests (quinter) · symfony/symfony@a70b537 · GitHub
[go: up one dir, main page]

Skip to content

Commit a70b537

Browse files
fix tests (quinter)
1 parent 21619fe commit a70b537

File tree

6 files changed

+16
-24
lines changed

6 files changed

+16
-24
lines changed

.travis.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ before_install:
4343
# General configuration
4444
set -e
4545
stty cols 120
46+
sudo sed -i 's/127\.0\.1\.1 localhost/127.0.0.1 localhost/' /etc/hosts
4647
cp .github/composer-config.json "$(composer config home)/config.json"
4748
git config --global user.email ""
4849
git config --global user.name "Symfony"

src/Symfony/Component/HttpClient/Tests/CurlHttpClientTest.php

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -38,16 +38,15 @@ protected function getHttpClient(string $testCase): HttpClientInterface
3838
public function testBindToPort()
3939
{
4040
$client = $this->getHttpClient(__FUNCTION__);
41-
$localhost = gethostbyname('localhost');
42-
$response = $client->request('GET', "http://$localhost:8057", ['bindto' => "$localhost:9876"]);
41+
$response = $client->request('GET', 'http://localhost:8057', ['bindto' => '127.0.0.1:9876']);
4342
$response->getStatusCode();
4443

4544
$r = new \ReflectionProperty($response, 'handle');
4645
$r->setAccessible(true);
4746

4847
$curlInfo = curl_getinfo($r->getValue($response));
4948

50-
self::assertSame($localhost, $curlInfo['local_ip']);
49+
self::assertSame('127.0.0.1', $curlInfo['local_ip']);
5150
self::assertSame(9876, $curlInfo['local_port']);
5251
}
5352

@@ -153,15 +152,13 @@ private function getVulcainClient(): CurlHttpClient
153152
return $client;
154153
}
155154

156-
$localhost = gethostbyname('localhost');
157-
158-
if (['application/json'] !== $client->request('GET', "http://$localhost:8057/json")->getHeaders()['content-type']) {
155+
if (['application/json'] !== $client->request('GET', 'http://127.0.0.1:8057/json')->getHeaders()['content-type']) {
159156
$this->markTestSkipped('symfony/http-client-contracts >= 2.0.1 required');
160157
}
161158

162159
$process = new Process(['vulcain'], null, [
163160
'DEBUG' => 1,
164-
'UPSTREAM' => "http://$localhost:8057",
161+
'UPSTREAM' => 'http://127.0.0.1:8057',
165162
'ADDR' => ':3000',
166163
'KEY_FILE' => __DIR__.'/Fixtures/tls/server.key',
167164
'CERT_FILE' => __DIR__.'/Fixtures/tls/server.crt',

src/Symfony/Component/HttpClient/composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
"require": {
2424
"php": ">=7.1.3",
2525
"psr/log": "^1.0",
26-
"symfony/http-client-contracts": "^1.1.11|~2.1.4|~2.2.1|~2.3.2|^2.4.1",
26+
"symfony/http-client-contracts": "^1.1.10|^2",
2727
"symfony/polyfill-php73": "^1.11",
2828
"symfony/service-contracts": "^1.0|^2"
2929
},

src/Symfony/Contracts/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&# 6D40 39;);
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

src/Symfony/Contracts/HttpClient/Test/HttpClientTestCase.php

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

354353
$expected = [
355354
'HTTP/1.1 301 Moved Permanently',
356-
"Location: http://$localhost:8057/302",
355+
'Location: http://127.0.0.1:8057/302',
357356
'Content-Type: application/json',
358357
'HTTP/1.1 302 Found',
359358
'Location: http://localhost:8057/',
@@ -426,7 +425,6 @@ public function testRedirect307()
426425
public function testMaxRedirects()
427426
{
428427
$client = $this->getHttpClient(__FUNCTION__);
429-
$localhost = gethostbyname('localhost');
430428
$response = $client->request('GET', 'http://localhost:8057/301', [
431429
'max_redirects' => 1,
432430
'auth_basic' => 'foo:bar',
@@ -444,7 +442,7 @@ public function testMaxRedirects()
444442

445443
$expected = [
446444
'HTTP/1.1 301 Moved Permanently',
447-
"Location: http://$localhost:8057/302",
445+
'Location: http://127.0.0.1:8057/302',
448446
'Content-Type: application/json',
449447
'HTTP/1.1 302 Found',
450448
'Location: http://localhost:8057/',
@@ -693,9 +691,8 @@ public function testOnProgressError()
693691
public function testResolve()
694692
{
695693
$client = $this->getHttpClient(__FUNCTION__);
696-
$localhost = gethostbyname('localhost');
697694
$response = $client->request('GET', 'http://symfony.com:8057/', [
698-
'resolve' => ['symfony.com' => $localhost],
695+
'resolve' => ['symfony.com' => '127.0.0.1'],
699696
]);
700697

701698
$this->assertSame(200, $response->getStatusCode());
@@ -709,16 +706,15 @@ public function testResolve()
709706
public function testIdnResolve()
710707
{
711708
$client = $this->getHttpClient(__FUNCTION__);
712-
$localhost = gethostbyname('localhost');
713709

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

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

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

724720
$this->assertSame(200, $response->getStatusCode());
@@ -860,7 +856,7 @@ public function testProxy()
860856

861857
$body = $response->toArray();
862858
$this->assertSame('localhost:8057', $body['HTTP_HOST']);
863-
$this->assertMatchesRegularExpression('#^http://(localhost|127\.0\.\d+\.1):8057/$#', $body['REQUEST_URI']);
859+
$this->assertMatchesRegularExpression('#^http://(localhost|127\.0\.0\.1):8057/$#', $body['REQUEST_URI']);
864860

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

src/Symfony/Contracts/HttpClient/Test/TestHttpServer.php

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

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

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

4544
return $process;
4645
}

0 commit comments

Comments
 (0)
0