mirror of
https://github.com/stan220/testcontainers-php.git
synced 2026-09-08 17:29:29 +00:00
feat: Add postgres container
This commit is contained in:
@@ -9,6 +9,7 @@ use Redis;
|
||||
use Testcontainer\Container\MariaDBContainer;
|
||||
use Testcontainer\Container\MySQLContainer;
|
||||
use Testcontainer\Container\OpenSearchContainer;
|
||||
use Testcontainer\Container\PostgresContainer;
|
||||
use Testcontainer\Container\RedisContainer;
|
||||
|
||||
class ContainerTest extends TestCase
|
||||
@@ -95,4 +96,26 @@ class ContainerTest extends TestCase
|
||||
|
||||
$this->assertEquals('docker-cluster', $data['cluster_name']);
|
||||
}
|
||||
|
||||
public function testPostgreSQLContainer(): void
|
||||
{
|
||||
$container = PostgresContainer::make('latest', 'test')
|
||||
->withPostgresUser('test')
|
||||
->withPostgresDatabase('foo');
|
||||
|
||||
|
||||
$pdo = new \PDO(
|
||||
sprintf('postgres:host=%s;port=3306', $container->getAddress()),
|
||||
'test',
|
||||
'test',
|
||||
);
|
||||
|
||||
$query = $pdo->query('SHOW databases');
|
||||
|
||||
$this->assertInstanceOf(\PDOStatement::class, $query);
|
||||
|
||||
$databases = $query->fetchAll(\PDO::FETCH_COLUMN);
|
||||
|
||||
$this->assertContains('foo', $databases);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user