abstract class PostgreSqlContainer
    extends GenericContainer

Defines a reusable PostgreSQL server with a disposable test database.

Each version extends it and sets only $IMAGE. The server is ready once it logs that it accepts connections; the user is test / test.

Properties§

protected static $EXPOSED_PORTS = [5432]
protected static $ENVIRONMENTS = ['POSTGRES_USER' => 'test', 'POSTGRES_PASSWORD' => 'test', 'POSTGRES_DB' => 'te…
protected static $REUSE_MODE = 'reuse'
protected static $STARTUP_TIMEOUT = 300
protected static $STARTUP_CONFLICT_RETRY_ATTEMPTS = 10
protected static $AUTO_REMOVE_ON_EXIT = true

Methods§

public static function getGrammarVersion(): string

Returns the SQL grammar identifier matching the server version.

Returns

string Grammar identifier, `pg-` followed by the image tag.
Calls 2
public function afterStart(ContainerInstance $instance): void

Attaches the server endpoint once the container has started.

The host is given as 127.0.0.1 instead of localhost so that clients connect over TCP.

Parameters

$instanceContainerInstanceStarted container instance.

Throws

RuntimeException If the server port is not mapped to the host.
Calls 6
protected function waitStrategy(ContainerInstance $instance): WaitStrategy

Waits until the server logs that it accepts connections.

Parameters

$instanceContainerInstanceStarted container instance.

Returns

WaitStrategy Log message wait strategy.
Calls 2
  • method-call LogMessageWaitStrategy::withPattern() line 72
  • new LogMessageWaitStrategy line 72

Relations§

Extended by 2