Files
testcontainers-php/tests/Integration/MySQLContainerTest.php
T
Sergei Shitikov f05ea0020d - Move most of the stuff for backwards compatibility support into one class
- Added random port logic
- Updated wait wtrategies
- API alignments to make it similar to other official implementations
- ...
2024-09-06 19:08:37 +02:00

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);
}
}