Files
testcontainers-php/tests/Integration/MongoDBContainerTest.php
2025-05-08 10:47:41 +03:00

32 lines
765 B
PHP

<?php
declare(strict_types=1);
namespace Integration;
use Testcontainers\Container\StartedGenericContainer;
use Testcontainers\Modules\MongoDBContainer;
use Testcontainers\Tests\Integration\ContainerTestCase;
class MongoDBContainerTest extends ContainerTestCase
{
public function setUp(): void
{
$this->container = (new MongoDBContainer())->start();
}
public function testMongoDBContainer(): void
{
self::assertInstanceOf(StartedGenericContainer::class, $this->container);
$pingResult = $this->container->exec([
'mongosh', 'admin',
'-u', 'test',
'-p', 'test',
'--eval', "'db.runCommand(\"ping\").ok'",
]);
self::assertEquals(1, $pingResult);
}
}