refactor Container to GenericContainer for better align to other Testcontainers language packages

This commit is contained in:
Sergei Shitikov
2024-08-22 16:45:47 +02:00
parent c82e974ab9
commit 27caae56c0
10 changed files with 22 additions and 22 deletions
@@ -23,7 +23,7 @@ use Testcontainers\Wait\WaitInterface;
* @phpstan-type ContainerInspect ContainerInspectSingleNetwork|ContainerInspectMultipleNetworks
* @phpstan-type DockerNetwork array{CreatedAt: string, Driver: string, ID: string, IPv6: string, Internal: string, Labels: string, Name: string, Scope: string}
*/
class Container
class GenericContainer
{
protected Docker $dockerClient;
@@ -67,7 +67,7 @@ class Container
public static function make(string $image): self
{
return new Container($image);
return new GenericContainer($image);
}
public function getId(): string
+1 -1
View File
@@ -6,7 +6,7 @@ namespace Testcontainers\Container;
use Testcontainers\Wait\WaitForExec;
class MariaDBContainer extends Container
class MariaDBContainer extends GenericContainer
{
private function __construct(string $version, string $mysqlRootPassword)
{
+1 -1
View File
@@ -6,7 +6,7 @@ namespace Testcontainers\Container;
use Testcontainers\Wait\WaitForExec;
class MySQLContainer extends Container
class MySQLContainer extends GenericContainer
{
private function __construct(string $version, string $mysqlRootPassword)
{
+1 -1
View File
@@ -6,7 +6,7 @@ namespace Testcontainers\Container;
use Testcontainers\Wait\WaitForHttp;
class OpenSearchContainer extends Container
class OpenSearchContainer extends GenericContainer
{
private function __construct(string $version)
{
+1 -1
View File
@@ -6,7 +6,7 @@ namespace Testcontainers\Container;
use Testcontainers\Wait\WaitForExec;
class PostgresContainer extends Container
class PostgresContainer extends GenericContainer
{
private function __construct(string $version, string $rootPassword)
{
+1 -1
View File
@@ -6,7 +6,7 @@ namespace Testcontainers\Container;
use Testcontainers\Wait\WaitForLog;
class RedisContainer extends Container
class RedisContainer extends GenericContainer
{
private function __construct(string $version)
{
+4 -4
View File
@@ -4,18 +4,18 @@ declare(strict_types=1);
namespace Testcontainers;
use Testcontainers\Container\Container;
use Testcontainers\Container\GenericContainer;
class Registry
{
private static bool $registeredCleanup = false;
/**
* @var array<int|string, Container>
* @var array<int|string, GenericContainer>
*/
private static array $registry = [];
public static function add(Container $container): void
public static function add(GenericContainer $container): void
{
self::$registry[spl_object_id($container)] = $container;
@@ -25,7 +25,7 @@ class Registry
}
}
public static function remove(Container $container): void
public static function remove(GenericContainer $container): void
{
unset(self::$registry[spl_object_id($container)]);
}
+3 -3
View File
@@ -6,12 +6,12 @@ namespace Testcontainers\Trait;
use JsonException;
use Symfony\Component\Process\Process;
use Testcontainers\Container\Container;
use Testcontainers\Container\GenericContainer;
use UnexpectedValueException;
/**
* @phpstan-import-type ContainerInspect from Container
* @phpstan-import-type DockerNetwork from Container
* @phpstan-import-type ContainerInspect from GenericContainer
* @phpstan-import-type DockerNetwork from GenericContainer
*/
trait DockerContainerAwareTrait
{