diff --git a/src/TestContainer/WaitForHttp.php b/src/TestContainer/WaitForHttp.php index ffca8f8..2822aeb 100644 --- a/src/TestContainer/WaitForHttp.php +++ b/src/TestContainer/WaitForHttp.php @@ -85,10 +85,7 @@ public function wait(StartedTestContainer $startedTestContainer): void $containerAddress = $startedTestContainer->getHost(); - $storage = iterator_to_array($startedTestContainer->getBoundPorts()); - $port = array_key_exists($this->port . '/tcp', $storage) ? $storage[$this->port . '/tcp'][0]->getHostPort() : $this->port; - - $url = sprintf('%s://%s:%d%s', $this->protocol, $containerAddress, $port, $this->path); + $url = sprintf('%s://%s:%d%s', $this->protocol, $containerAddress, $startedTestContainer->getMappedPort($this->port), $this->path); $responseCode = $this->makeHttpRequest($url); if ($responseCode === $this->expectedStatusCode) { diff --git a/tests/Stream/CurlMultiHandlerTest.php b/tests/Stream/CurlMultiHandlerTest.php index 0e907c4..78caebc 100644 --- a/tests/Stream/CurlMultiHandlerTest.php +++ b/tests/Stream/CurlMultiHandlerTest.php @@ -82,7 +82,7 @@ public function testExecuteThrowsIfHandleMissing(): void public function testExecuteThrowsIfHostNotExists(): void { $this->expectException(RuntimeException::class); - $this->expectExceptionMessageMatches("#Internal HttpClient: cURL handle execution failed with error: Failed to connect to [^ ]+ port 1234 after \d+ ms: Couldn't connect to server#"); + $this->expectExceptionMessageMatches("#Internal HttpClient: cURL handle execution failed with error: Failed to connect to [^ ]+ port 1234 after \d+ ms: [^ ]+#"); $host = $this->container->getHost(); $baseUrl = "http://{$host}:1234";