mirror of
https://github.com/stan220/testcontainers-php.git
synced 2026-09-12 11:29:36 +00:00
fix: Tests and postgres image
This commit is contained in:
@@ -20,7 +20,7 @@ jobs:
|
|||||||
uses: shivammathur/setup-php@v2
|
uses: shivammathur/setup-php@v2
|
||||||
with:
|
with:
|
||||||
php-version: '8.1'
|
php-version: '8.1'
|
||||||
extensions: redis
|
extensions: redis, pgsql
|
||||||
|
|
||||||
- name: Install dependencies
|
- name: Install dependencies
|
||||||
run: composer install --prefer-dist --no-progress
|
run: composer install --prefer-dist --no-progress
|
||||||
|
|||||||
@@ -4,12 +4,15 @@ declare(strict_types=1);
|
|||||||
|
|
||||||
namespace Testcontainer\Container;
|
namespace Testcontainer\Container;
|
||||||
|
|
||||||
|
use Testcontainer\Wait\WaitForExec;
|
||||||
|
|
||||||
class PostgresContainer extends Container
|
class PostgresContainer extends Container
|
||||||
{
|
{
|
||||||
private function __construct(string $version, string $rootPassword)
|
private function __construct(string $version, string $rootPassword)
|
||||||
{
|
{
|
||||||
parent::__construct('mariadb:' . $version);
|
parent::__construct('postgres:' . $version);
|
||||||
$this->withEnvironment('POSTGRES_PASSWORD', $rootPassword);
|
$this->withEnvironment('POSTGRES_PASSWORD', $rootPassword);
|
||||||
|
$this->withWait(new WaitForExec(["pg_isready", "-h", "127.0.0.1"]));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function make(string $version = 'latest', string $mysqlRootPassword = 'root'): self
|
public static function make(string $version = 'latest', string $mysqlRootPassword = 'root'): self
|
||||||
|
|||||||
@@ -101,11 +101,12 @@ class ContainerTest extends TestCase
|
|||||||
{
|
{
|
||||||
$container = PostgresContainer::make('latest', 'test')
|
$container = PostgresContainer::make('latest', 'test')
|
||||||
->withPostgresUser('test')
|
->withPostgresUser('test')
|
||||||
->withPostgresDatabase('foo');
|
->withPostgresDatabase('foo')
|
||||||
|
->run();
|
||||||
|
|
||||||
|
|
||||||
$pdo = new \PDO(
|
$pdo = new \PDO(
|
||||||
sprintf('postgres:host=%s;port=3306', $container->getAddress()),
|
sprintf('postgres:host=%s;port=5432', $container->getAddress()),
|
||||||
'test',
|
'test',
|
||||||
'test',
|
'test',
|
||||||
);
|
);
|
||||||
|
|||||||
Reference in New Issue
Block a user