some reordering and test optimizations to align new API.

This commit is contained in:
Sergei Shitikov
2024-09-01 14:45:04 +02:00
parent b0e4f60592
commit 5ee4fdc804
6 changed files with 206 additions and 0 deletions
@@ -0,0 +1,35 @@
<?php
declare(strict_types=1);
namespace Testcontainers\Tests\Integration;
use Testcontainers\Container\PostgresContainer;
class PostgreSQLContainerTest extends ContainerTestCase
{
public static function setUpBeforeClass(): void
{
self::$container = (new PostgresContainer('latest', 'test'))
->withPostgresUser('test')
->withPostgresDatabase('foo')
->start();
}
public function testPostgreSQLContainer(): void
{
$pdo = new \PDO(
sprintf('pgsql:host=%s;port=5432;dbname=foo', self::$container->getAddress()),
'test',
'test',
);
$query = $pdo->query('SELECT datname FROM pg_database');
$this->assertInstanceOf(\PDOStatement::class, $query);
$databases = $query->fetchAll(\PDO::FETCH_COLUMN);
$this->assertContains('foo', $databases);
}
}