mirror of
https://github.com/stan220/testcontainers-php.git
synced 2026-09-08 22:29:46 +00:00
36 lines
835 B
PHP
36 lines
835 B
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace Testcontainers\Tests\Integration;
|
|
|
|
use Testcontainers\Container\MySQLContainer;
|
|
|
|
class MySQLContainerTest extends ContainerTestCase
|
|
{
|
|
public static function setUpBeforeClass(): void
|
|
{
|
|
self::$container = (new MySQLContainer())
|
|
->withMySQLDatabase('foo')
|
|
->withMySQLUser('bar', 'baz')
|
|
->start();
|
|
}
|
|
|
|
public function testMySQLContainer(): void
|
|
{
|
|
$pdo = new \PDO(
|
|
sprintf('mysql:host=%s;port=3306', self::$container->getAddress()),
|
|
'bar',
|
|
'baz',
|
|
);
|
|
|
|
$query = $pdo->query('SHOW databases');
|
|
|
|
$this->assertInstanceOf(\PDOStatement::class, $query);
|
|
|
|
$databases = $query->fetchAll(\PDO::FETCH_COLUMN);
|
|
|
|
$this->assertContains('foo', $databases);
|
|
}
|
|
}
|