From a5e85b38626f5b6b6fdbfe547f6f7c632308efe3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Tamarelle?= Date: Wed, 29 Oct 2025 15:52:18 +0100 Subject: [PATCH] Make `MONGODB_URI` configurable for functional tests (#931) * Make server URI configurable for functional tests * Use MONGODB_URI --- phpunit.xml.dist | 2 +- tests/Command/CommandTestKernel.php | 2 +- tests/DocumentValueResolverFunctionalTest.php | 2 +- tests/TestCase.php | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/phpunit.xml.dist b/phpunit.xml.dist index 2ef3bde..a8cc034 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -20,7 +20,7 @@ - + diff --git a/tests/Command/CommandTestKernel.php b/tests/Command/CommandTestKernel.php index bc6958d..19abc84 100644 --- a/tests/Command/CommandTestKernel.php +++ b/tests/Command/CommandTestKernel.php @@ -44,7 +44,7 @@ final class CommandTestKernel extends Kernel ]); $container->loadFromExtension('doctrine_mongodb', [ - 'connections' => ['default' => []], + 'connections' => ['default' => ['server' => '%env(MONGODB_URI)%']], 'document_managers' => [ 'command_test' => [ 'connection' => 'default', diff --git a/tests/DocumentValueResolverFunctionalTest.php b/tests/DocumentValueResolverFunctionalTest.php index 5fb5146..41255d2 100644 --- a/tests/DocumentValueResolverFunctionalTest.php +++ b/tests/DocumentValueResolverFunctionalTest.php @@ -111,7 +111,7 @@ class FooTestKernel extends Kernel ]); $c->loadFromExtension('doctrine_mongodb', [ - 'connections' => ['default' => []], + 'connections' => ['default' => ['server' => '%env(MONGODB_URI)%']], 'document_managers' => [ 'default' => [ 'mappings' => [ diff --git a/tests/TestCase.php b/tests/TestCase.php index 13ffb25..2b1492e 100644 --- a/tests/TestCase.php +++ b/tests/TestCase.php @@ -27,7 +27,7 @@ class TestCase extends BaseTestCase $config->setHydratorNamespace('SymfonyTests\Doctrine'); $config->setMetadataDriverImpl(new AttributeDriver($paths)); $config->setMetadataCache(new ArrayAdapter()); - $uri = getenv('DOCTRINE_MONGODB_SERVER') ?: 'mongodb://localhost:27017'; + $uri = getenv('MONGODB_URI'); return DocumentManager::create(new Client($uri), $config); }