Skip to content

Commit 55c9f3c

Browse files
wundiiawu
andauthored
chore: update WaitForHttp and refine exception message in tests (#53)
Co-authored-by: awu <andreas.wunderwald@westpress.de>
1 parent 0d38969 commit 55c9f3c

2 files changed

Lines changed: 2 additions & 5 deletions

File tree

src/TestContainer/WaitForHttp.php

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -85,10 +85,7 @@ public function wait(StartedTestContainer $startedTestContainer): void
8585

8686
$containerAddress = $startedTestContainer->getHost();
8787

88-
$storage = iterator_to_array($startedTestContainer->getBoundPorts());
89-
$port = array_key_exists($this->port . '/tcp', $storage) ? $storage[$this->port . '/tcp'][0]->getHostPort() : $this->port;
90-
91-
$url = sprintf('%s://%s:%d%s', $this->protocol, $containerAddress, $port, $this->path);
88+
$url = sprintf('%s://%s:%d%s', $this->protocol, $containerAddress, $startedTestContainer->getMappedPort($this->port), $this->path);
9289
$responseCode = $this->makeHttpRequest($url);
9390

9491
if ($responseCode === $this->expectedStatusCode) {

tests/Stream/CurlMultiHandlerTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ public function testExecuteThrowsIfHandleMissing(): void
8282
public function testExecuteThrowsIfHostNotExists(): void
8383
{
8484
$this->expectException(RuntimeException::class);
85-
$this->expectExceptionMessageMatches("#Internal HttpClient: cURL handle execution failed with error: Failed to connect to [^ ]+ port 1234 after \d+ ms: Couldn't connect to server#");
85+
$this->expectExceptionMessageMatches("#Internal HttpClient: cURL handle execution failed with error: Failed to connect to [^ ]+ port 1234 after \d+ ms: [^ ]+#");
8686

8787
$host = $this->container->getHost();
8888
$baseUrl = "http://{$host}:1234";

0 commit comments

Comments
 (0)