Skip to content

Commit e2eb7e4

Browse files
Merge branch '5.0' into 5.1
* 5.0: [Mime] Remove unused var [HttpClient] fix monitoring timeouts when other streams are active [PhpUnitBridge] fix syntax on PHP 5.3 [PhpUnitBridge] Fix undefined index when output of "composer show" cannot be parsed properly cascade validation to child forms [PhpUnitBridge] fix undefined var on version 3.4 Move ajax clear event listener initialization on loadToolbar [HttpClient] Throw JsonException instead of TransportException on empty response in Response::toArray() take into account the context when preserving empty array objects [VarExporter] tfix: s/markAsSkipped/markTestSkipped/ bumped Symfony version to 5.0.10 updated VERSION for 5.0.9 updated CHANGELOG for 5.0.9 bumped Symfony version to 4.4.10 updated VERSION for 4.4.9 updated CHANGELOG for 4.4.9 bumped Symfony version to 3.4.42 updated VERSION for 3.4.41 update CONTRIBUTORS for 3.4.41 updated CHANGELOG for 3.4.41
2 parents 6e0a672 + 4b7ee80 commit e2eb7e4

File tree

2 files changed

+36
-7
lines changed

2 files changed

+36
-7
lines changed

Test/HttpClientTestCase.php

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -811,6 +811,30 @@ public function testUncheckedTimeoutThrows()
811811
}
812812
}
813813

814+
public function testTimeoutWithActiveConcurrentStream()
815+
{
816+
$p1 = TestHttpServer::start(8067);
817+
$p2 = TestHttpServer::start(8077);
818+
819+
$client = $this->getHttpClient(__FUNCTION__);
820+
$streamingResponse = $client->request('GET', 'http://localhost:8067/max-duration');
821+
$blockingResponse = $client->request('GET', 'http://localhost:8077/timeout-body', [
822+
'timeout' => 0.25,
823+
]);
824+
825+
$this->assertSame(200, $streamingResponse->getStatusCode());
826+
$this->assertSame(200, $blockingResponse->getStatusCode());
827+
828+
$this->expectException(TransportExceptionInterface::class);
829+
830+
try {
831+
$blockingResponse->getContent();
832+
} finally {
833+
$p1->stop();
834+
$p2->stop();
835+
}
836+
}
837+
814838
public function testDestruct()
815839
{
816840
$client = $this->getHttpClient(__FUNCTION__);

Test/TestHttpServer.php

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,23 +16,28 @@
1616

1717
class TestHttpServer
1818
{
19-
private static $process;
19+
private static $process = [];
2020

21-
public static function start()
21+
public static function start(int $port = 8057)
2222
{
23-
if (self::$process) {
24-
self::$process->stop();
23+
if (isset(self::$process[$port])) {
24+
self::$process[$port]->stop();
25+
} else {
26+
register_shutdown_function(static function () use ($port) {
27+
self::$process[$port]->stop();
28+
});
2529
}
2630

2731
$finder = new PhpExecutableFinder();
28-
$process = new Process(array_merge([$finder->find(false)], $finder->findArguments(), ['-dopcache.enable=0', '-dvariables_order=EGPCS', '-S', '127.0.0.1:8057']));
32+
$process = new Process(array_merge([$finder->find(false)], $finder->findArguments(), ['-dopcache.enable=0', '-dvariables_order=EGPCS', '-S', '127.0.0.1:'.$port]));
2933
$process->setWorkingDirectory(__DIR__.'/Fixtures/web');
3034
$process->start();
35+
self::$process[$port] = $process;
3136

3237
do {
3338
usleep(50000);
34-
} while (!@fopen('http://127.0.0.1:8057/', 'r'));
39+
} while (!@fopen('http://127.0.0.1:'.$port, 'r'));
3540

36-
self::$process = $process;
41+
return $process;
3742
}
3843
}

0 commit comments

Comments
 (0)