mirror of
https://github.com/stan220/testcontainers-php.git
synced 2026-09-08 23:29:31 +00:00
added beluga-php/docker-php client and some basic updates to the base Container class
This commit is contained in:
@@ -4,13 +4,11 @@ declare(strict_types=1);
|
||||
|
||||
namespace Testcontainers\Wait;
|
||||
|
||||
use Docker\Docker;
|
||||
use Testcontainers\Exception\ContainerNotReadyException;
|
||||
use Testcontainers\Trait\DockerContainerAwareTrait;
|
||||
|
||||
class WaitForHttp implements WaitInterface
|
||||
{
|
||||
use DockerContainerAwareTrait;
|
||||
|
||||
public const METHOD_GET = 'GET';
|
||||
public const METHOD_POST = 'POST';
|
||||
public const METHOD_PUT = 'PUT';
|
||||
@@ -22,9 +20,11 @@ class WaitForHttp implements WaitInterface
|
||||
private string $method = 'GET';
|
||||
private string $path = '/';
|
||||
private int $statusCode = 200;
|
||||
private Docker $dockerClient;
|
||||
|
||||
public function __construct(private int $port)
|
||||
{
|
||||
$this->dockerClient = Docker::create();
|
||||
}
|
||||
|
||||
public static function make(int $port): self
|
||||
@@ -58,7 +58,14 @@ class WaitForHttp implements WaitInterface
|
||||
|
||||
public function wait(string $id): void
|
||||
{
|
||||
$containerAddress = self::dockerContainerAddress(containerId: $id);
|
||||
$containerNetworks = $this->dockerClient->containerInspect($id)->getNetworkSettings()->getNetworks();
|
||||
$containerAddress = null;
|
||||
foreach ($containerNetworks as $network) {
|
||||
if($network->getNetworkID() === $id) {
|
||||
$containerAddress = $network->getIpAddress();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
$ch = curl_init();
|
||||
curl_setopt($ch, CURLOPT_URL, sprintf('http://%s:%d%s', $containerAddress, $this->port, $this->path));
|
||||
|
||||
Reference in New Issue
Block a user