mirror of
https://github.com/stan220/testcontainers-php.git
synced 2026-09-08 19:29:39 +00:00
- Added random port logic - Updated wait wtrategies - API alignments to make it similar to other official implementations - ...
40 lines
930 B
PHP
40 lines
930 B
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace Testcontainers\Tests\Integration;
|
|
|
|
use Testcontainers\Modules\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=%d',
|
|
self::$container->getHost(),
|
|
self::$container->getFirstMappedPort()
|
|
),
|
|
'bar',
|
|
'baz',
|
|
);
|
|
|
|
$query = $pdo->query('SHOW databases');
|
|
|
|
$this->assertInstanceOf(\PDOStatement::class, $query);
|
|
|
|
$databases = $query->fetchAll(\PDO::FETCH_COLUMN);
|
|
|
|
$this->assertContains('foo', $databases);
|
|
}
|
|
}
|