Fix tests (bis)
This commit is contained in:
parent
fb79727653
commit
7341e29f2f
@ -33,6 +33,7 @@
|
|||||||
"php-http/httplug": "^1.0|^2.0",
|
"php-http/httplug": "^1.0|^2.0",
|
||||||
"psr/http-client": "^1.0",
|
"psr/http-client": "^1.0",
|
||||||
"symfony/dependency-injection": "^4.3|^5.0",
|
"symfony/dependency-injection": "^4.3|^5.0",
|
||||||
|
"symfony/http-client-contracts": "^1.1.11|~2.1.4|~2.2.1|~2.3.2|^2.4.1",
|
||||||
"symfony/http-kernel": "^4.4.13",
|
"symfony/http-kernel": "^4.4.13",
|
||||||
"symfony/process": "^4.2|^5.0"
|
"symfony/process": "^4.2|^5.0"
|
||||||
},
|
},
|
||||||
|
@ -65,7 +65,8 @@ class MimeTypeTest extends TestCase
|
|||||||
|
|
||||||
public function testGuessWithDuplicatedFileType()
|
public function testGuessWithDuplicatedFileType()
|
||||||
{
|
{
|
||||||
$this->assertSame('application/vnd.openxmlformats-officedocument.wordprocessingml.document', MimeTypeGuesser::getInstance()->guess(__DIR__.'/../Fixtures/test.docx'));
|
$type = MimeTypeGuesser::getInstance()->guess(__DIR__.'/../Fixtures/test.docx');
|
||||||
|
$this->assertTrue(\in_array($type, ['application/vnd.openxmlformats-officedocument.wordprocessingml.document', 'application/zip'], true));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testGuessWithIncorrectPath()
|
public function testGuessWithIncorrectPath()
|
||||||
|
@ -20,4 +20,9 @@ class FileBinaryMimeTypeGuesserTest extends AbstractMimeTypeGuesserTest
|
|||||||
{
|
{
|
||||||
return new FileBinaryMimeTypeGuesser();
|
return new FileBinaryMimeTypeGuesser();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function testGuessWithDuplicatedFileType()
|
||||||
|
{
|
||||||
|
$this->markTestSkipped('Result varies depending on the OS');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -30,6 +30,7 @@ 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:
|
||||||
@ -41,7 +42,7 @@ switch ($vars['REQUEST_URI']) {
|
|||||||
|
|
||||||
case '/':
|
case '/':
|
||||||
case '/?a=a&b=b':
|
case '/?a=a&b=b':
|
||||||
case 'http://127.0.0.1:8057/':
|
case "http://$localhost:8057/":
|
||||||
case 'http://localhost:8057/':
|
case 'http://localhost:8057/':
|
||||||
ob_start('ob_gzhandler');
|
ob_start('ob_gzhandler');
|
||||||
break;
|
break;
|
||||||
@ -74,7 +75,7 @@ switch ($vars['REQUEST_URI']) {
|
|||||||
|
|
||||||
case '/301':
|
case '/301':
|
||||||
if ('Basic Zm9vOmJhcg==' === $vars['HTTP_AUTHORIZATION']) {
|
if ('Basic Zm9vOmJhcg==' === $vars['HTTP_AUTHORIZATION']) {
|
||||||
header('Location: http://127.0.0.1:8057/302', true, 301);
|
header("Location: http://$localhost:8057/302", true, 301);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -335,6 +335,7 @@ 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 +353,7 @@ abstract class HttpClientTestCase extends TestCase
|
|||||||
|
|
||||||
$expected = [
|
$expected = [
|
||||||
'HTTP/1.1 301 Moved Permanently',
|
'HTTP/1.1 301 Moved Permanently',
|
||||||
'Location: http://127.0.0.1:8057/302',
|
"Location: http://$localhost: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,6 +426,7 @@ 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',
|
||||||
@ -442,7 +444,7 @@ abstract class HttpClientTestCase extends TestCase
|
|||||||
|
|
||||||
$expected = [
|
$expected = [
|
||||||
'HTTP/1.1 301 Moved Permanently',
|
'HTTP/1.1 301 Moved Permanently',
|
||||||
'Location: http://127.0.0.1:8057/302',
|
"Location: http://$localhost: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/',
|
||||||
@ -691,8 +693,9 @@ 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' => '127.0.0.1'],
|
'resolve' => ['symfony.com' => $localhost],
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$this->assertSame(200, $response->getStatusCode());
|
$this->assertSame(200, $response->getStatusCode());
|
||||||
@ -706,15 +709,16 @@ 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' => '127.0.0.1'],
|
'resolve' => ['0-------------------------------------------------------------0.com' => $localhost],
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$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' => '127.0.0.1'],
|
'resolve' => ['xn--bcher-kva.example' => $localhost],
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$this->assertSame(200, $response->getStatusCode());
|
$this->assertSame(200, $response->getStatusCode());
|
||||||
|
@ -31,15 +31,16 @@ 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', '127.0.0.1:'.$port]));
|
$process = new Process(array_merge([$finder->find(false)], $finder->findArguments(), ['-dopcache.enable=0', '-dvariables_order=EGPCS', '-S', "$localhost:$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://127.0.0.1:'.$port, 'r'));
|
} while (!@fopen("http://$localhost:$port", 'r'));
|
||||||
|
|
||||||
return $process;
|
return $process;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user