Update vendor folder

This commit is contained in:
Frédéric Guillot
2020-08-17 21:21:20 -07:00
parent d958ddef2c
commit 81019680fa
81 changed files with 1655 additions and 1683 deletions

View File

@@ -1,4 +1,4 @@
Copyright (c) 2018-2019 Fabien Potencier
Copyright (c) 2018-2020 Fabien Potencier
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal

View File

@@ -155,6 +155,27 @@ switch ($vars['REQUEST_URI']) {
usleep(500);
}
exit;
case '/json':
header("Content-Type: application/json");
echo json_encode([
'documents' => [
['id' => '/json/1'],
['id' => '/json/2'],
['id' => '/json/3'],
],
]);
exit;
case '/json/1':
case '/json/2':
case '/json/3':
header("Content-Type: application/json");
echo json_encode([
'title' => $vars['REQUEST_URI'],
]);
exit;
}
header('Content-Type: application/json', true);

View File

@@ -24,8 +24,6 @@ use Symfony\Contracts\HttpClient\HttpClientInterface;
*/
abstract class HttpClientTestCase extends TestCase
{
private static $server;
public static function setUpBeforeClass(): void
{
TestHttpServer::start();
@@ -166,7 +164,7 @@ abstract class HttpClientTestCase extends TestCase
$client = $this->getHttpClient(__FUNCTION__);
$response = $client->request('GET', 'http://localhost:8057', ['buffer' => function () {
throw new \Exception('Boo');
throw new \Exception('Boo.');
}]);
$this->assertSame(200, $response->getStatusCode());
@@ -648,7 +646,7 @@ abstract class HttpClientTestCase extends TestCase
$response = $client->request('GET', 'http://localhost:8057/timeout-body', [
'on_progress' => function ($dlNow) {
if (0 < $dlNow) {
throw new \Exception('Aborting the request');
throw new \Exception('Aborting the request.');
}
},
]);
@@ -658,7 +656,7 @@ abstract class HttpClientTestCase extends TestCase
}
$this->fail(ClientExceptionInterface::class.' expected');
} catch (TransportExceptionInterface $e) {
$this->assertSame('Aborting the request', $e->getPrevious()->getMessage());
$this->assertSame('Aborting the request.', $e->getPrevious()->getMessage());
}
$this->assertNotNull($response->getInfo('error'));
@@ -672,7 +670,7 @@ abstract class HttpClientTestCase extends TestCase
$response = $client->request('GET', 'http://localhost:8057/timeout-body', [
'on_progress' => function ($dlNow) {
if (0 < $dlNow) {
throw new \Error('BUG');
throw new \Error('BUG.');
}
},
]);
@@ -682,7 +680,7 @@ abstract class HttpClientTestCase extends TestCase
}
$this->fail('Error expected');
} catch (\Error $e) {
$this->assertSame('BUG', $e->getMessage());
$this->assertSame('BUG.', $e->getMessage());
}
$this->assertNotNull($response->getInfo('error'));
@@ -705,6 +703,23 @@ abstract class HttpClientTestCase extends TestCase
$client->request('GET', 'http://symfony.com:8057/', ['timeout' => 1]);
}
public function testIdnResolve()
{
$client = $this->getHttpClient(__FUNCTION__);
$response = $client->request('GET', 'http://0-------------------------------------------------------------0.com:8057/', [
'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' => '127.0.0.1'],
]);
$this->assertSame(200, $response->getStatusCode());
}
public function testNotATimeout()
{
$client = $this->getHttpClient(__FUNCTION__);
@@ -771,6 +786,30 @@ abstract class HttpClientTestCase extends TestCase
}
}
public function testTimeoutWithActiveConcurrentStream()
{
$p1 = TestHttpServer::start(8067);
$p2 = TestHttpServer::start(8077);
$client = $this->getHttpClient(__FUNCTION__);
$streamingResponse = $client->request('GET', 'http://localhost:8067/max-duration');
$blockingResponse = $client->request('GET', 'http://localhost:8077/timeout-body', [
'timeout' => 0.25,
]);
$this->assertSame(200, $streamingResponse->getStatusCode());
$this->assertSame(200, $blockingResponse->getStatusCode());
$this->expectException(TransportExceptionInterface::class);
try {
$blockingResponse->getContent();
} finally {
$p1->stop();
$p2->stop();
}
}
public function testDestruct()
{
$client = $this->getHttpClient(__FUNCTION__);
@@ -784,6 +823,18 @@ abstract class HttpClientTestCase extends TestCase
$this->assertLessThan(4, $duration);
}
public function testGetContentAfterDestruct()
{
$client = $this->getHttpClient(__FUNCTION__);
try {
$client->request('GET', 'http://localhost:8057/404');
$this->fail(ClientExceptionInterface::class.' expected');
} catch (ClientExceptionInterface $e) {
$this->assertSame('GET', $e->getResponse()->toArray(false)['REQUEST_METHOD']);
}
}
public function testProxy()
{
$client = $this->getHttpClient(__FUNCTION__);

View File

@@ -19,31 +19,28 @@ use Symfony\Component\Process\Process;
*/
class TestHttpServer
{
private static $server;
private static $process = [];
public static function start()
public static function start(int $port = 8057)
{
if (null !== self::$server) {
return;
if (isset(self::$process[$port])) {
self::$process[$port]->stop();
} else {
register_shutdown_function(static function () use ($port) {
self::$process[$port]->stop();
});
}
$finder = new PhpExecutableFinder();
$process = new Process(array_merge([$finder->find(false)], $finder->findArguments(), ['-dopcache.enable=0', '-dvariables_order=EGPCS', '-S', '127.0.0.1:8057']));
$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->setTimeout(300);
$process->start();
self::$process[$port] = $process;
self::$server = new class() {
public $process;
do {
usleep(50000);
} while (!@fopen('http://127.0.0.1:'.$port, 'r'));
public function __destruct()
{
$this->process->stop();
}
};
self::$server->process = $process;
sleep('\\' === \DIRECTORY_SEPARATOR ? 10 : 1);
return $process;
}
}

View File

@@ -16,7 +16,7 @@
}
],
"require": {
"php": "^7.1.3"
"php": ">=7.1.3"
},
"suggest": {
"symfony/http-client-implementation": ""
@@ -28,6 +28,10 @@
"extra": {
"branch-alias": {
"dev-master": "1.1-dev"
},
"thanks": {
"name": "symfony/contracts",
"url": "https://github.com/symfony/contracts"
}
}
}