Merge branch '4.4' into 5.2

* 4.4:
  fix tests (quinter)
This commit is contained in:
Nicolas Grekas 2021-06-07 21:00:30 +02:00
commit e98baf5ea6
7 changed files with 16 additions and 24 deletions

View File

@ -44,6 +44,7 @@ before_install:
# General configuration # General configuration
set -e set -e
stty cols 120 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" cp .github/composer-config.json "$(composer config home)/config.json"
git config --global user.email "" git config --global user.email ""
git config --global user.name "Symfony" git config --global user.name "Symfony"

View File

@ -38,8 +38,7 @@ class CurlHttpClientTest extends HttpClientTestCase
public function testBindToPort() public function testBindToPort()
{ {
$client = $this->getHttpClient(__FUNCTION__); $client = $this->getHttpClient(__FUNCTION__);
$localhost = gethostbyname('localhost'); $response = $client->request('GET', 'http://localhost:8057', ['bindto' => '127.0.0.1:9876']);
$response = $client->request('GET', "http://$localhost:8057", ['bindto' => "$localhost:9876"]);
$response->getStatusCode(); $response->getStatusCode();
$r = new \ReflectionProperty($response, 'handle'); $r = new \ReflectionProperty($response, 'handle');
@ -47,7 +46,7 @@ class CurlHttpClientTest extends HttpClientTestCase
$curlInfo = curl_getinfo($r->getValue($response)); $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']); self::assertSame(9876, $curlInfo['local_port']);
} }

View File

@ -298,15 +298,13 @@ abstract class HttpClientTestCase extends BaseHttpClientTestCase
self::markTestSkipped('Testing with the "vulcain" is not supported on Windows.'); self::markTestSkipped('Testing with the "vulcain" is not supported on Windows.');
} }
$localhost = gethostbyname('localhost'); if (['application/json'] !== $client->request('GET', 'http://127.0.0.1:8057/json')->getHeaders()['content-type']) {
if (['application/json'] !== $client->request('GET', "http://$localhost:8057/json")->getHeaders()['content-type']) {
self::markTestSkipped('symfony/http-client-contracts >= 2.0.1 required'); self::markTestSkipped('symfony/http-client-contracts >= 2.0.1 required');
} }
$process = new Process(['vulcain'], null, [ $process = new Process(['vulcain'], null, [
'DEBUG' => 1, 'DEBUG' => 1,
'UPSTREAM' => "http://$localhost:8057", 'UPSTREAM' => 'http://127.0.0.1:8057',
'ADDR' => ':3000', 'ADDR' => ':3000',
'KEY_FILE' => __DIR__.'/Fixtures/tls/server.key', 'KEY_FILE' => __DIR__.'/Fixtures/tls/server.key',
'CERT_FILE' => __DIR__.'/Fixtures/tls/server.crt', 'CERT_FILE' => __DIR__.'/Fixtures/tls/server.crt',

View File

@ -23,7 +23,7 @@
"require": { "require": {
"php": ">=7.2.5", "php": ">=7.2.5",
"psr/log": "^1.0", "psr/log": "^1.0",
"symfony/http-client-contracts": "~2.2.1|~2.3.2|^2.4.1", "symfony/http-client-contracts": "^2.2",
"symfony/polyfill-php73": "^1.11", "symfony/polyfill-php73": "^1.11",
"symfony/polyfill-php80": "^1.15", "symfony/polyfill-php80": "^1.15",
"symfony/service-contracts": "^1.0|^2" "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); $json = json_encode($vars, \JSON_PRETTY_PRINT | \JSON_UNESCAPED_SLASHES | \JSON_UNESCAPED_UNICODE);
$localhost = gethostbyname('localhost');
switch ($vars['REQUEST_URI']) { switch ($vars['REQUEST_URI']) {
default: default:
@ -42,7 +41,7 @@ switch ($vars['REQUEST_URI']) {
case '/': case '/':
case '/?a=a&b=b': case '/?a=a&b=b':
case "http://$localhost:8057/": case 'http://127.0.0.1:8057/':
case 'http://localhost:8057/': case 'http://localhost:8057/':
ob_start('ob_gzhandler'); ob_start('ob_gzhandler');
break; break;
@ -75,7 +74,7 @@ switch ($vars['REQUEST_URI']) {
case '/301': case '/301':
if ('Basic Zm9vOmJhcg==' === $vars['HTTP_AUTHORIZATION']) { 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; break;

View File

@ -334,7 +334,6 @@ abstract class HttpClientTestCase extends TestCase
public function testRedirects() public function testRedirects()
{ {
$client = $this->getHttpClient(__FUNCTION__); $client = $this->getHttpClient(__FUNCTION__);
$localhost = gethostbyname('localhost');
$response = $client->request('POST', 'http://localhost:8057/301', [ $response = $client->request('POST', 'http://localhost:8057/301', [
'auth_basic' => 'foo:bar', 'auth_basic' => 'foo:bar',
'body' => function () { 'body' => function () {
@ -352,7 +351,7 @@ abstract class HttpClientTestCase extends TestCase
$expected = [ $expected = [
'HTTP/1.1 301 Moved Permanently', 'HTTP/1.1 301 Moved Permanently',
"Location: http://$localhost:8057/302", 'Location: http://127.0.0.1:8057/302',
'Content-Type: application/json', 'Content-Type: application/json',
'HTTP/1.1 302 Found', 'HTTP/1.1 302 Found',
'Location: http://localhost:8057/', 'Location: http://localhost:8057/',
@ -425,7 +424,6 @@ abstract class HttpClientTestCase extends TestCase
public function testMaxRedirects() public function testMaxRedirects()
{ {
$client = $this->getHttpClient(__FUNCTION__); $client = $this->getHttpClient(__FUNCTION__);
$localhost = gethostbyname('localhost');
$response = $client->request('GET', 'http://localhost:8057/301', [ $response = $client->request('GET', 'http://localhost:8057/301', [
'max_redirects' => 1, 'max_redirects' => 1,
'auth_basic' => 'foo:bar', 'auth_basic' => 'foo:bar',
@ -443,7 +441,7 @@ abstract class HttpClientTestCase extends TestCase
$expected = [ $expected = [
'HTTP/1.1 301 Moved Permanently', 'HTTP/1.1 301 Moved Permanently',
"Location: http://$localhost:8057/302", 'Location: http://127.0.0.1:8057/302',
'Content-Type: application/json', 'Content-Type: application/json',
'HTTP/1.1 302 Found', 'HTTP/1.1 302 Found',
'Location: http://localhost:8057/', 'Location: http://localhost:8057/',
@ -692,9 +690,8 @@ abstract class HttpClientTestCase extends TestCase
public function testResolve() public function testResolve()
{ {
$client = $this->getHttpClient(__FUNCTION__); $client = $this->getHttpClient(__FUNCTION__);
$localhost = gethostbyname('localhost');
$response = $client->request('GET', 'http://symfony.com:8057/', [ $response = $client->request('GET', 'http://symfony.com:8057/', [
'resolve' => ['symfony.com' => $localhost], 'resolve' => ['symfony.com' => '127.0.0.1'],
]); ]);
$this->assertSame(200, $response->getStatusCode()); $this->assertSame(200, $response->getStatusCode());
@ -708,16 +705,15 @@ abstract class HttpClientTestCase extends TestCase
public function testIdnResolve() public function testIdnResolve()
{ {
$client = $this->getHttpClient(__FUNCTION__); $client = $this->getHttpClient(__FUNCTION__);
$localhost = gethostbyname('localhost');
$response = $client->request('GET', 'http://0-------------------------------------------------------------0.com:8057/', [ $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()); $this->assertSame(200, $response->getStatusCode());
$response = $client->request('GET', 'http://Bücher.example:8057/', [ $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()); $this->assertSame(200, $response->getStatusCode());
@ -885,7 +881,7 @@ abstract class HttpClientTestCase extends TestCase
$body = $response->toArray(); $body = $response->toArray();
$this->assertSame('localhost:8057', $body['HTTP_HOST']); $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/', [ $response = $client->request('GET', 'http://localhost:8057/', [
'proxy' => 'http://foo:b%3Dar@localhost:8057', 'proxy' => 'http://foo:b%3Dar@localhost:8057',

View File

@ -28,16 +28,15 @@ class TestHttpServer
}); });
} }
$localhost = gethostbyname('localhost');
$finder = new PhpExecutableFinder(); $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->setWorkingDirectory(__DIR__.'/Fixtures/web');
$process->start(); $process->start();
self::$process[$port] = $process; self::$process[$port] = $process;
do { do {
usleep(50000); usleep(50000);
} while (!@fopen("http://$localhost:$port", 'r')); } while (!@fopen('http://127.0.0.1:'.$port, 'r'));
return $process; return $process;
} }