final class PostgreSqlRelease

Resolves a PostgreSQL release number to the container that runs it.

Tests and fuzz targets start the release named by PG_VERSION, so CI runs the newest release and a developer runs any other release locally by setting the variable.

Resolve the container of a releasedoctest
assert(\Container\PostgreSqlRelease::container('16.6') === \Container\PostgreSql16Container::class);
Resolve the release named by the environment, falling back to the defaultdoctest
putenv('PG_VERSION');
    assert(\Container\PostgreSqlRelease::fromEnvironment() === \Container\PostgreSql17Container::class);

Constants§

public const DEFAULT = '17.2'
public const VARIABLE = 'PG_VERSION'

Methods§

public static function versions(): list<string>

Lists the release numbers with a container, oldest first.

Returns

list<string>
Called from 2
Calls 2
public static function latest(): string

Names the newest release with a container.

Returns

string
Calls 3
public static function container(string|null $version = null): class-string<PostgreSqlContainer>

Names the container of a release.

Parameters

$versionstring|nullRelease number such as `17.2`, or null for the default

Returns

class-string<PostgreSqlContainer>

Throws

RuntimeException If no container runs the release
Called from 1
Calls 6
public static function fromEnvironment(string $variable = self::VARIABLE): class-string<PostgreSqlContainer>

Names the container of the release given by an environment variable.

Parameters

$variablestringEnvironment variable holding the release number

Returns

class-string<PostgreSqlContainer>

Throws

RuntimeException If no container runs the release
Test cases 115
Calls 3

Private surface 1§

Implementation details, listed for orientation only.

private const array<string, class-string<PostgreSqlContainer>> CONTAINERS = ['16.6' => \Container\PostgreSql16Container::class, '17.2' => \Container\Postgr…

Test cases 116§

Test cases that cover or call this symbol, from the coverage report and from the analyzed test sources.

Other tests reaching this symbol 116