Merge branch '5.0'
* 5.0: [HttpClient] improve testTimeoutIsNotAFatalError Fix for #36715
This commit is contained in:
commit
53423db039
@ -109,7 +109,7 @@ abstract class HttpClientTestCase extends BaseHttpClientTestCase
|
|||||||
{
|
{
|
||||||
$client = $this->getHttpClient(__FUNCTION__);
|
$client = $this->getHttpClient(__FUNCTION__);
|
||||||
$response = $client->request('GET', 'http://localhost:8057/timeout-body', [
|
$response = $client->request('GET', 'http://localhost:8057/timeout-body', [
|
||||||
'timeout' => 0.1,
|
'timeout' => 0.3,
|
||||||
]);
|
]);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
@ -118,8 +118,17 @@ abstract class HttpClientTestCase extends BaseHttpClientTestCase
|
|||||||
} catch (TransportException $e) {
|
} catch (TransportException $e) {
|
||||||
}
|
}
|
||||||
|
|
||||||
usleep(400000);
|
for ($i = 0; $i < 10; ++$i) {
|
||||||
$this->assertSame('<1><2>', $response->getContent());
|
try {
|
||||||
|
$this->assertSame('<1><2>', $response->getContent());
|
||||||
|
break;
|
||||||
|
} catch (TransportException $e) {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (10 === $i) {
|
||||||
|
throw $e;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testResponseStreamRewind()
|
public function testResponseStreamRewind()
|
||||||
|
@ -51,7 +51,7 @@ final class MimeTypes implements MimeTypesInterface
|
|||||||
$this->extensions[$mimeType] = $extensions;
|
$this->extensions[$mimeType] = $extensions;
|
||||||
|
|
||||||
foreach ($extensions as $extension) {
|
foreach ($extensions as $extension) {
|
||||||
$this->mimeTypes[$extension] = $mimeType;
|
$this->mimeTypes[$extension][] = $mimeType;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$this->registerGuesser(new FileBinaryMimeTypeGuesser());
|
$this->registerGuesser(new FileBinaryMimeTypeGuesser());
|
||||||
|
@ -62,4 +62,15 @@ class MimeTypesTest extends AbstractMimeTypeGuesserTest
|
|||||||
$this->assertContains('image/svg', $mt->getMimeTypes('svg'));
|
$this->assertContains('image/svg', $mt->getMimeTypes('svg'));
|
||||||
$this->assertSame([], $mt->getMimeTypes('symfony'));
|
$this->assertSame([], $mt->getMimeTypes('symfony'));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function testCustomMimeTypes()
|
||||||
|
{
|
||||||
|
$mt = new MimeTypes([
|
||||||
|
'text/bar' => ['foo'],
|
||||||
|
'text/baz' => ['foo', 'moof'],
|
||||||
|
]);
|
||||||
|
$this->assertContains('text/bar', $mt->getMimeTypes('foo'));
|
||||||
|
$this->assertContains('text/baz', $mt->getMimeTypes('foo'));
|
||||||
|
$this->assertSame(['foo', 'moof'], $mt->getExtensions('text/baz'));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user