minor #41594 fix tests (quinter) (nicolas-grekas)

This PR was merged into the 4.4 branch.

Discussion
----------

fix tests (quinter)

| Q             | A
| ------------- | ---
| Branch?       | 4.4
| Bug fix?      | no
| New feature?  | no
| Deprecations? | no
| Tickets       | -
| License       | MIT
| Doc PR        | -

Commits
-------

a70b537fbc fix tests (quinter)
This commit is contained in:
Nicolas Grekas 2021-06-07 20:58:54 +02:00
commit a4dee4aaba
6 changed files with 16 additions and 24 deletions

View File

@ -43,6 +43,7 @@ before_install:
# General configuration
set -e
stty cols 120
sudo sed -i 's/127\.0\.1\.1 localhost/127.0.0.1 localhost/' /etc/hosts
cp .github/composer-config.json "$(composer config home)/config.json"
git config --global user.email ""
git config --global user.name "Symfony"

View File

@ -38,8 +38,7 @@ class CurlHttpClientTest extends HttpClientTestCase
public function testBindToPort()
{
$client = $this->getHttpClient(__FUNCTION__);
$localhost = gethostbyname('localhost');
$response = $client->request('GET', "http://$localhost:8057", ['bindto' => "$localhost:9876"]);
$response = $client->request('GET', 'http://localhost:8057', ['bindto' => '127.0.0.1:9876']);
$response->getStatusCode();
$r = new \ReflectionProperty($response, 'handle');
@ -47,7 +46,7 @@ class CurlHttpClientTest extends HttpClientTestCase
$curlInfo = curl_getinfo($r->getValue($response));
self::assertSame($localhost, $curlInfo['local_ip']);
self::assertSame('127.0.0.1', $curlInfo['local_ip']);
self::assertSame(9876, $curlInfo['local_port']);
}
@ -153,15 +152,13 @@ class CurlHttpClientTest extends HttpClientTestCase
return $client;
}
$localhost = gethostbyname('localhost');
if (['application/json'] !== $client->request('GET', "http://$localhost:8057/json")->getHeaders()['content-type']) {
if (['application/json'] !== $client->request('GET', 'http://127.0.0.1:8057/json')->getHeaders()['content-type']) {
$this->markTestSkipped('symfony/http-client-contracts >= 2.0.1 required');
}
$process = new Process(['vulcain'], null, [
'DEBUG' => 1,
'UPSTREAM' => "http://$localhost:8057",
'UPSTREAM' => 'http://127.0.0.1:8057',
'ADDR' => ':3000',
'KEY_FILE' => __DIR__.'/Fixtures/tls/server.key',
'CERT_FILE' => __DIR__.'/Fixtures/tls/server.crt',

View File

@ -23,7 +23,7 @@
"require": {
"php": ">=7.1.3",
"psr/log": "^1.0",
"symfony/http-client-contracts": "^1.1.11|~2.1.4|~2.2.1|~2.3.2|^2.4.1",
"symfony/http-client-contracts": "^1.1.10|^2",
"symfony/polyfill-php73": "^1.11",
"symfony/service-contracts": "^1.0|^2"
},

View File

@ -30,7 +30,6 @@ foreach ($_SERVER as $k => $v) {
}
$json = json_encode($vars, \JSON_PRETTY_PRINT | \JSON_UNESCAPED_SLASHES | \JSON_UNESCAPED_UNICODE);
$localhost = gethostbyname('localhost');
switch ($vars['REQUEST_URI']) {
default:
@ -42,7 +41,7 @@ switch ($vars['REQUEST_URI']) {
case '/':
case '/?a=a&b=b':
case "http://$localhost:8057/":
case 'http://127.0.0.1:8057/':
case 'http://localhost:8057/':
ob_start('ob_gzhandler');
break;
@ -75,7 +74,7 @@ switch ($vars['REQUEST_URI']) {
case '/301':
if ('Basic Zm9vOmJhcg==' === $vars['HTTP_AUTHORIZATION']) {
header("Location: http://$localhost:8057/302", true, 301);
header('Location: http://127.0.0.1:8057/302', true, 301);
}
break;

View File

@ -335,7 +335,6 @@ abstract class HttpClientTestCase extends TestCase
public function testRedirects()
{
$client = $this->getHttpClient(__FUNCTION__);
$localhost = gethostbyname('localhost');
$response = $client->request('POST', 'http://localhost:8057/301', [
'auth_basic' => 'foo:bar',
'body' => function () {
@ -353,7 +352,7 @@ abstract class HttpClientTestCase extends TestCase
$expected = [
'HTTP/1.1 301 Moved Permanently',
"Location: http://$localhost:8057/302",
'Location: http://127.0.0.1:8057/302',
'Content-Type: application/json',
'HTTP/1.1 302 Found',
'Location: http://localhost:8057/',
@ -426,7 +425,6 @@ abstract class HttpClientTestCase extends TestCase
public function testMaxRedirects()
{
$client = $this->getHttpClient(__FUNCTION__);
$localhost = gethostbyname('localhost');
$response = $client->request('GET', 'http://localhost:8057/301', [
'max_redirects' => 1,
'auth_basic' => 'foo:bar',
@ -444,7 +442,7 @@ abstract class HttpClientTestCase extends TestCase
$expected = [
'HTTP/1.1 301 Moved Permanently',
"Location: http://$localhost:8057/302",
'Location: http://127.0.0.1:8057/302',
'Content-Type: application/json',
'HTTP/1.1 302 Found',
'Location: http://localhost:8057/',
@ -693,9 +691,8 @@ abstract class HttpClientTestCase extends TestCase
public function testResolve()
{
$client = $this->getHttpClient(__FUNCTION__);
$localhost = gethostbyname('localhost');
$response = $client->request('GET', 'http://symfony.com:8057/', [
'resolve' => ['symfony.com' => $localhost],
'resolve' => ['symfony.com' => '127.0.0.1'],
]);
$this->assertSame(200, $response->getStatusCode());
@ -709,16 +706,15 @@ abstract class HttpClientTestCase extends TestCase
public function testIdnResolve()
{
$client = $this->getHttpClient(__FUNCTION__);
$localhost = gethostbyname('localhost');
$response = $client->request('GET', 'http://0-------------------------------------------------------------0.com:8057/', [
'resolve' => ['0-------------------------------------------------------------0.com' => $localhost],
'resolve' => ['0-------------------------------------------------------------0.com' => '127.0.0.1'],
]);
$this->assertSame(200, $response->getStatusCode());
$response = $client->request('GET', 'http://Bücher.example:8057/', [
'resolve' => ['xn--bcher-kva.example' => $localhost],
'resolve' => ['xn--bcher-kva.example' => '127.0.0.1'],
]);
$this->assertSame(200, $response->getStatusCode());
@ -860,7 +856,7 @@ abstract class HttpClientTestCase extends TestCase
$body = $response->toArray();
$this->assertSame('localhost:8057', $body['HTTP_HOST']);
$this->assertMatchesRegularExpression('#^http://(localhost|127\.0\.\d+\.1):8057/$#', $body['REQUEST_URI']);
$this->assertMatchesRegularExpression('#^http://(localhost|127\.0\.0\.1):8057/$#', $body['REQUEST_URI']);
$response = $client->request('GET', 'http://localhost:8057/', [
'proxy' => 'http://foo:b%3Dar@localhost:8057',

View File

@ -31,16 +31,15 @@ class TestHttpServer
});
}
$localhost = gethostbyname('localhost');
$finder = new PhpExecutableFinder();
$process = new Process(array_merge([$finder->find(false)], $finder->findArguments(), ['-dopcache.enable=0', '-dvariables_order=EGPCS', '-S', "$localhost:$port"]));
$process = new Process(array_merge([$finder->find(false)], $finder->findArguments(), ['-dopcache.enable=0', '-dvariables_order=EGPCS', '-S', '127.0.0.1:'.$port]));
$process->setWorkingDirectory(__DIR__.'/Fixtures/web');
$process->start();
self::$process[$port] = $process;
do {
usleep(50000);
} while (!@fopen("http://$localhost:$port", 'r'));
} while (!@fopen('http://127.0.0.1:'.$port, 'r'));
return $process;
}