adjust wait for host port strategy

This commit is contained in:
Sergei Shitikov
2025-02-16 18:02:16 +01:00
parent 1f7178e313
commit 5e86ed1443
5 changed files with 36 additions and 18 deletions
+2 -4
View File
@@ -7,7 +7,6 @@ namespace Testcontainers\Tests\Integration;
use Docker\API\Model\ContainersIdJsonGetResponse200;
use PHPUnit\Framework\TestCase;
use Testcontainers\Container\GenericContainer;
use Testcontainers\Utils\PortGenerator\FixedPortGenerator;
use Testcontainers\Wait\WaitForHostPort;
class GenericContainerTest extends TestCase
@@ -115,13 +114,12 @@ class GenericContainerTest extends TestCase
public function testShouldReturnFirstMappedPort(): void
{
$container = (new GenericContainer('nginx'))
->withPortGenerator(new FixedPortGenerator([9090]))
->withExposedPorts(80)
->withWait(new WaitForHostPort(9090))
->withWait(new WaitForHostPort())
->start();
$firstMappedPort = $container->getFirstMappedPort();
self::assertSame($firstMappedPort, 9090, 'First mapped port does not match 9090');
self::assertSame($firstMappedPort, $container->getMappedPort(80));
$container->stop();
}
@@ -5,6 +5,7 @@ declare(strict_types=1);
namespace Testcontainers\Tests\Integration;
use Testcontainers\Container\GenericContainer;
use Testcontainers\Wait\WaitForHostPort;
class StartedGenericContainerTest extends ContainerTestCase
{