diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index cc5b9ee..5e68d91 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -1,13 +1,10 @@ name: Test on: - pull_request: - branches: - - "v*.*" - - "feature/*" + pull_request: ~ push: branches: - - "v*.*" + - "*.*" - "feature/*" permissions: @@ -47,6 +44,7 @@ jobs: php-version: - '8.1' - '8.2' + - '8.3' dependencies: - 'highest' - 'lowest' @@ -56,6 +54,7 @@ jobs: - 'normal' - 'symfony/symfony:"6.3.*"' - 'symfony/symfony:"6.4.*"' + - 'symfony/symfony:"7.0.*"' steps: - name: Checkout diff --git a/README.md b/README.md index 27e9c5a..2cf4295 100644 --- a/README.md +++ b/README.md @@ -55,11 +55,12 @@ mongodb: clients: default: uri: '%env(MONGODB_URI)%' - uriOptions: #... - driverOptions: #... + default_database: #... + uri_options: #... + driver_options: #... ``` -The `uriOptions` and `driverOptions` are passed directly to the underlying MongoDB driver. +The `uri_options` and `driver_options` are passed directly to the underlying MongoDB driver. See the [documentation](https://www.php.net/manual/en/mongodb-driver-manager.construct.php) for available options. If you want to configure multiple clients, you can do so by adding additional clients to the configuration: @@ -96,7 +97,8 @@ class MyService } ``` -If you register multiple clients, you can autowire them by name + `Client` suffix: +If you register multiple clients, you can autowire them by using the client name with a `Client` suffix as parameter +name: ```php use MongoDB\Bundle\Attribute\AutowireClient; @@ -105,6 +107,7 @@ use MongoDB\Client; class MyService { public function __construct( + // Will autowire the client with the id "second" private Client $secondClient, ) {} } @@ -119,16 +122,16 @@ use MongoDB\Client; class MyService { public function __construct( - #[AutowireClient('second')] + #[AutowireClient('second')] private Client $client, ) {} } ``` -## Database and Collection Usage +## Database Usage -The client service provides access to databases and collections. You can access a database by calling the `selectDatabase` -method, passing the database name and potential options: +The client service provides access to databases and collections. You can access a database by calling the +`selectDatabase` method, passing the database name and potential options: ```php use MongoDB\Client; @@ -146,7 +149,7 @@ class MyService } ``` -An alternative to this is using the `AutowireDatabase` attribute, referencing the database name: +An alternative to this is using the `#[AutowireDatabase]` attribute, referencing the database name: ```php use MongoDB\Bundle\Attribute\AutowireDatabase; @@ -161,21 +164,9 @@ class MyService } ``` -You can also omit the `database` option if the property name matches the database name. -In the following example the database name is `myDatabase`, inferred from the property name: - -```php -use MongoDB\Bundle\Attribute\AutowireCollection; -use MongoDB\Collection; - -class MyService -{ - public function __construct( - #[AutowireCollection()] - private Collection $myDatabase, - ) {} -} -``` +If you don't specify a database name in the attribute, the default database name (specified in the `default_database` +configuration option) will be used. If you did not define a default database, the database name has to be specified in +the attribute. If you have more than one client defined, you can also reference the client: @@ -192,8 +183,10 @@ class MyService } ``` +## Collection Usage + To inject a collection, you can either call the `selectCollection` method on a `Client` or `Database` instance. -For convenience, the `AutowireCollection` attribute provides a quicker alternative: +For convenience, the `#[AutowireCollection]` attribute provides a quicker alternative: ```php use MongoDB\Bundle\Attribute\AutowireCollection; @@ -230,6 +223,7 @@ class MyService ``` If you have more than one client defined, you can also reference the client: + ```php use MongoDB\Bundle\Attribute\AutowireCollection; use MongoDB\Collection; @@ -245,3 +239,54 @@ class MyService ) {} } ``` + +By specifiying the `default_database` option in the configuration, you can omit the `database` option in the +`AutowireCollection` attribute: + +```diff +mongodb: + clients: + default: + uri: '%env(MONGODB_URI)%' ++ default_database: 'myDatabase' +``` + +```php +use MongoDB\Bundle\Attribute\AutowireCollection; +use MongoDB\Collection; + +class MyService +{ + public function __construct( + #[AutowireCollection] + private Collection $myCollection, + ) {} +} +``` + +## Specifying options + +When using the `AutowireDatabase` or `AutowireCollection` attributes, you can specify additional options for the +resulting instances. You can pass the following options: +|| Option || Accepted type || +| `codec` | `DocumentCodec` instance | +| `typeMap`| `array` containing type map information | +| `readPreference` | `MongoDB\Driver\ReadPreference` instance | +| `writeConcern` | `MongoDB\Driver\writeConcern` instance | +| `readConcern` | `MongoDB\Driver\ReadConcern` instance | + +In addition to passing an instance, you can also pass a service reference by specifying a string for the given option: + +```php +use MongoDB\Bundle\Attribute\AutowireCollection; +use MongoDB\Collection; +use MongoDB\Driver\ReadPreference; + +class MyService +{ + public function __construct( + #[AutowireCollection(codec: Codec::class, readPreference: new ReadPreference('secondary'))] + private Collection $myCollection, + ) {} +} +``` diff --git a/composer.json b/composer.json index 85a93df..72f42e8 100644 --- a/composer.json +++ b/composer.json @@ -13,21 +13,21 @@ ], "require": { "php": ">=8.1", - "mongodb/mongodb": "^1.16", - "symfony/config": "^6.3", - "symfony/console": "^6.3", - "symfony/dependency-injection": "^6.3.5", - "symfony/http-kernel": "^6.3", - "symfony/runtime": "^6.3" + "mongodb/mongodb": "^1.17", + "symfony/config": "^6.3 || ^7.0", + "symfony/console": "^6.3 || ^7.0", + "symfony/dependency-injection": "^6.3.5 || ^7.0", + "symfony/http-kernel": "^6.3.5 || ^7.0", + "symfony/runtime": "^6.3 || ^7.0" }, "require-dev": { "doctrine/coding-standard": "^12.0", "rector/rector": "^0.18", - "symfony/browser-kit": "^6.3", - "symfony/filesystem": "^6.3", - "symfony/framework-bundle": "^6.3.5", - "symfony/phpunit-bridge": "^6.3", - "symfony/yaml": "^6.3", + "symfony/browser-kit": "^6.3 || ^7.0", + "symfony/filesystem": "^6.3 || ^7.0", + "symfony/framework-bundle": "^6.3.5 || ^7.0", + "symfony/phpunit-bridge": "~6.3.10 || ^6.4.1 || ^7.0.1", + "symfony/yaml": "^6.3 || ^7.0", "zenstruck/browser": "^1.6" }, "scripts": { diff --git a/src/Attribute/AutowireCollection.php b/src/Attribute/AutowireCollection.php index 957d77b..6f99bb4 100644 --- a/src/Attribute/AutowireCollection.php +++ b/src/Attribute/AutowireCollection.php @@ -23,13 +23,18 @@ use Attribute; use MongoDB\Bundle\DependencyInjection\MongoDBExtension; use MongoDB\Client; +use MongoDB\Codec\DocumentCodec; use MongoDB\Collection; +use MongoDB\Driver\ReadConcern; +use MongoDB\Driver\ReadPreference; +use MongoDB\Driver\WriteConcern; use ReflectionParameter; use Symfony\Component\DependencyInjection\Attribute\AutowireCallable; use Symfony\Component\DependencyInjection\Definition; use Symfony\Component\DependencyInjection\Reference; use function is_string; +use function ltrim; use function sprintf; /** @@ -44,7 +49,11 @@ public function __construct( private readonly ?string $collection = null, private readonly ?string $database = null, ?string $client = null, - private readonly array $options = [], + private readonly string|DocumentCodec|null $codec = null, + private readonly string|array|null $typeMap = null, + private readonly string|ReadPreference|null $readPreference = null, + private readonly string|WriteConcern|null $writeConcern = null, + private readonly string|ReadConcern|null $readConcern = null, bool|string $lazy = false, ) { $this->serviceId = $client === null @@ -59,12 +68,27 @@ public function __construct( public function buildDefinition(mixed $value, ?string $type, ReflectionParameter $parameter): Definition { + $options = []; + foreach (['codec', 'typeMap', 'readPreference', 'writeConcern', 'readConcern'] as $option) { + $optionValue = $this->$option; + if ($optionValue === null) { + continue; + } + + // If a string was given, it may be a service ID or parameter. Handle it accordingly + if (is_string($optionValue)) { + $optionValue = $option === 'typeMap' ? sprintf('%%%s%%', $optionValue) : new Reference($optionValue); + } + + $options[$option] = $optionValue; + } + return (new Definition(is_string($this->lazy) ? $this->lazy : ($type ?: Collection::class))) ->setFactory($value) ->setArguments([ $this->database ?? sprintf('%%%s.default_database%%', $this->serviceId), $this->collection ?? $parameter->getName(), - $this->options, + $options, ]) ->setLazy($this->lazy); } diff --git a/src/Attribute/AutowireDatabase.php b/src/Attribute/AutowireDatabase.php index 1c94f35..0b9b56b 100644 --- a/src/Attribute/AutowireDatabase.php +++ b/src/Attribute/AutowireDatabase.php @@ -23,13 +23,18 @@ use Attribute; use MongoDB\Bundle\DependencyInjection\MongoDBExtension; use MongoDB\Client; +use MongoDB\Codec\DocumentCodec; use MongoDB\Database; +use MongoDB\Driver\ReadConcern; +use MongoDB\Driver\ReadPreference; +use MongoDB\Driver\WriteConcern; use ReflectionParameter; use Symfony\Component\DependencyInjection\Attribute\AutowireCallable; use Symfony\Component\DependencyInjection\Definition; use Symfony\Component\DependencyInjection\Reference; use function is_string; +use function sprintf; /** * Autowires a MongoDB database. @@ -37,27 +42,51 @@ #[Attribute(Attribute::TARGET_PARAMETER)] final class AutowireDatabase extends AutowireCallable { + private readonly string $serviceId; + public function __construct( private readonly ?string $database = null, ?string $client = null, - private readonly array $options = [], + private readonly string|DocumentCodec|null $codec = null, + private readonly string|array|null $typeMap = null, + private readonly string|ReadPreference|null $readPreference = null, + private readonly string|WriteConcern|null $writeConcern = null, + private readonly string|ReadConcern|null $readConcern = null, bool|string $lazy = false, ) { - $callable = $client === null - ? [new Reference(Client::class), 'selectDatabase'] - : [new Reference(MongoDBExtension::createClientServiceId($client)), 'selectDatabase']; + $this->serviceId = $client === null + ? Client::class + : MongoDBExtension::createClientServiceId($client); parent::__construct( - callable: $callable, + callable: [new Reference($this->serviceId), 'selectDatabase'], lazy: $lazy, ); } public function buildDefinition(mixed $value, ?string $type, ReflectionParameter $parameter): Definition { + $options = []; + foreach (['codec', 'typeMap', 'readPreference', 'writeConcern', 'readConcern'] as $option) { + $optionValue = $this->$option; + if ($optionValue === null) { + continue; + } + + // If a string was given, it may be a service ID or parameter. Handle it accordingly + if (is_string($optionValue)) { + $optionValue = $option === 'typeMap' ? sprintf('%%%s%%', $optionValue) : new Reference($optionValue); + } + + $options[$option] = $optionValue; + } + return (new Definition(is_string($this->lazy) ? $this->lazy : ($type ?: Database::class))) ->setFactory($value) - ->setArguments([$this->database ?? $parameter->getName(), $this->options]) + ->setArguments([ + $this->database ?? sprintf('%%%s.default_database%%', $this->serviceId), + $options, + ]) ->setLazy($this->lazy); } } diff --git a/src/DependencyInjection/Configuration.php b/src/DependencyInjection/Configuration.php index a15e512..2e106a5 100644 --- a/src/DependencyInjection/Configuration.php +++ b/src/DependencyInjection/Configuration.php @@ -32,11 +32,11 @@ public function getConfigTreeBuilder(): TreeBuilder ->scalarNode('uri') ->info('MongoDB connection string') ->end() - ->arrayNode('uriOptions') + ->arrayNode('uri_options') ->info('Additional connection string options') ->variablePrototype()->end() ->end() - ->arrayNode('driverOptions') + ->arrayNode('driver_options') ->info('Driver-specific options') ->variablePrototype()->end() ->end() diff --git a/src/DependencyInjection/MongoDBExtension.php b/src/DependencyInjection/MongoDBExtension.php index 4be5e36..a8b06e7 100644 --- a/src/DependencyInjection/MongoDBExtension.php +++ b/src/DependencyInjection/MongoDBExtension.php @@ -68,8 +68,8 @@ private function createClients(string $defaultClient, array $clients, ContainerB $clientDefinition = clone $clientPrototype; $clientDefinition->setArgument('$uri', $configuration['uri']); - $clientDefinition->setArgument('$uriOptions', $configuration['uriOptions'] ?? []); - $clientDefinition->setArgument('$driverOptions', $configuration['driverOptions'] ?? []); + $clientDefinition->setArgument('$uriOptions', $configuration['uri_options'] ?? []); + $clientDefinition->setArgument('$driverOptions', $configuration['driver_options'] ?? []); $container->setDefinition($serviceId, $clientDefinition); diff --git a/tests/TestApplication/src/Controller/AutowireDatabaseController.php b/tests/TestApplication/src/Controller/AutowireDatabaseController.php index 9529ec6..682e0a4 100644 --- a/tests/TestApplication/src/Controller/AutowireDatabaseController.php +++ b/tests/TestApplication/src/Controller/AutowireDatabaseController.php @@ -46,10 +46,10 @@ public function withoutArguments( /** @see AutowireClientTest::testWithCustomClientSetViaOptions() */ #[Route('/with-custom-client')] public function withCustomClient( - #[AutowireDatabase(client: FunctionalTestCase::CLIENT_ID_SECONDARY)] - Database $google, + #[AutowireDatabase(database: 'google', client: FunctionalTestCase::CLIENT_ID_SECONDARY)] + Database $database, ): JsonResponse { - $this->insertDocumentForDatabase($google, FunctionalTestCase::COLLECTION_USERS); + $this->insertDocumentForDatabase($database, FunctionalTestCase::COLLECTION_USERS); return new JsonResponse(); } diff --git a/tests/Unit/Attribute/AttributeTestCase.php b/tests/Unit/Attribute/AttributeTestCase.php new file mode 100644 index 0000000..e7ee39e --- /dev/null +++ b/tests/Unit/Attribute/AttributeTestCase.php @@ -0,0 +1,87 @@ + $codec, + 'writeConcern' => new WriteConcern(0), + 'readConcern' => new ReadConcern('majority'), + 'readPreference' => new ReadPreference('primary'), + ]; + + foreach ($options as $option => $value) { + yield sprintf('%s option: null', $option) => [ + 'attributeArguments' => [$option => null], + 'expectedOptions' => [], + ]; + + yield sprintf('%s option: instance', $option) => [ + 'attributeArguments' => [$option => $value], + 'expectedOptions' => [$option => $value], + ]; + + yield sprintf('%s option: reference', $option) => [ + 'attributeArguments' => [$option => sprintf('%s_service', $option)], + 'expectedOptions' => [$option => new Reference(sprintf('%s_service', $option))], + ]; + } + + // Type map + yield 'typeMap option: null' => [ + 'attributeArguments' => ['typeMap' => null], + 'expectedOptions' => [], + ]; + + yield 'typeMap option: value' => [ + 'attributeArguments' => ['typeMap' => ['root' => 'bson']], + 'expectedOptions' => ['typeMap' => ['root' => 'bson']], + ]; + + yield 'typeMap option: parameter' => [ + 'attributeArguments' => ['typeMap' => 'default_typeMap'], + 'expectedOptions' => ['typeMap' => '%default_typeMap%'], + ]; + } +} diff --git a/tests/Unit/Attribute/AutowireCollectionTest.php b/tests/Unit/Attribute/AutowireCollectionTest.php index 5f62a79..006a73d 100644 --- a/tests/Unit/Attribute/AutowireCollectionTest.php +++ b/tests/Unit/Attribute/AutowireCollectionTest.php @@ -23,14 +23,13 @@ use MongoDB\Bundle\Attribute\AutowireCollection; use MongoDB\Client; use MongoDB\Collection; -use PHPUnit\Framework\TestCase; use ReflectionParameter; use Symfony\Component\DependencyInjection\Reference; use function sprintf; /** @covers \MongoDB\Bundle\Attribute\AutowireCollection */ -final class AutowireCollectionTest extends TestCase +final class AutowireCollectionTest extends AttributeTestCase { public function testMinimal(): void { @@ -61,7 +60,6 @@ public function testCollection(): void collection: 'test', database: 'mydb', client: 'default', - options: ['foo' => 'bar'], ); $this->assertEquals([new Reference('mongodb.client.default'), 'selectCollection'], $autowire->value); @@ -80,7 +78,7 @@ static function (Collection $collection): void { $this->assertEquals($autowire->value, $definition->getFactory()); $this->assertSame('mydb', $definition->getArgument(0)); $this->assertSame('test', $definition->getArgument(1)); - $this->assertSame(['foo' => 'bar'], $definition->getArgument(2)); + $this->assertSame([], $definition->getArgument(2)); } public function testWithoutCollection(): void @@ -88,7 +86,6 @@ public function testWithoutCollection(): void $autowire = new AutowireCollection( database: 'mydb', client: 'default', - options: ['foo' => 'bar'], ); $this->assertEquals([new Reference('mongodb.client.default'), 'selectCollection'], $autowire->value); @@ -107,6 +104,28 @@ static function (Collection $priceReports): void { $this->assertEquals($autowire->value, $definition->getFactory()); $this->assertSame('mydb', $definition->getArgument(0)); $this->assertSame('priceReports', $definition->getArgument(1)); - $this->assertSame(['foo' => 'bar'], $definition->getArgument(2)); + $this->assertSame([], $definition->getArgument(2)); + } + + /** @dataProvider provideOptions */ + public function testWithOptions(array $attributeArguments, array $expectedOptions): void + { + $autowire = new AutowireCollection( + ...$attributeArguments, + database: 'mydb', + client: 'default', + ); + + $definition = $autowire->buildDefinition( + value: $autowire->value, + type: Collection::class, + parameter: new ReflectionParameter( + static function (Collection $priceReports): void { + }, + 'priceReports', + ), + ); + + $this->assertEquals($expectedOptions, $definition->getArgument(2)); } } diff --git a/tests/Unit/Attribute/AutowireDatabaseTest.php b/tests/Unit/Attribute/AutowireDatabaseTest.php index 4ccab63..1958e20 100644 --- a/tests/Unit/Attribute/AutowireDatabaseTest.php +++ b/tests/Unit/Attribute/AutowireDatabaseTest.php @@ -22,13 +22,13 @@ use MongoDB\Bundle\Attribute\AutowireDatabase; use MongoDB\Client; +use MongoDB\Collection; use MongoDB\Database; -use PHPUnit\Framework\TestCase; use ReflectionParameter; use Symfony\Component\DependencyInjection\Reference; /** @covers \MongoDB\Bundle\Attribute\AutowireDatabase */ -final class AutowireDatabaseTest extends TestCase +final class AutowireDatabaseTest extends AttributeTestCase { public function testMinimal(): void { @@ -48,7 +48,7 @@ static function (Database $mydb): void { $this->assertSame(Database::class, $definition->getClass()); $this->assertEquals($autowire->value, $definition->getFactory()); - $this->assertSame('mydb', $definition->getArgument(0)); + $this->assertSame('%MongoDB\Client.default_database%', $definition->getArgument(0)); } public function testDatabase(): void @@ -56,7 +56,6 @@ public function testDatabase(): void $autowire = new AutowireDatabase( database: 'mydb', client: 'default', - options: ['foo' => 'bar'], ); $this->assertEquals([new Reference('mongodb.client.default'), 'selectDatabase'], $autowire->value); @@ -74,14 +73,13 @@ static function (Database $db): void { $this->assertSame(Database::class, $definition->getClass()); $this->assertEquals($autowire->value, $definition->getFactory()); $this->assertSame('mydb', $definition->getArgument(0)); - $this->assertSame(['foo' => 'bar'], $definition->getArgument(1)); + $this->assertSame([], $definition->getArgument(1)); } public function testWithoutDatabase(): void { $autowire = new AutowireDatabase( client: 'default', - options: ['foo' => 'bar'], ); $this->assertEquals([new Reference('mongodb.client.default'), 'selectDatabase'], $autowire->value); @@ -98,7 +96,28 @@ static function (Database $mydb): void { $this->assertSame(Database::class, $definition->getClass()); $this->assertEquals($autowire->value, $definition->getFactory()); - $this->assertSame('mydb', $definition->getArgument(0)); - $this->assertSame(['foo' => 'bar'], $definition->getArgument(1)); + $this->assertSame('%mongodb.client.default.default_database%', $definition->getArgument(0)); + $this->assertSame([], $definition->getArgument(1)); + } + + /** @dataProvider provideOptions */ + public function testWithOptions(array $attributeArguments, array $expectedOptions): void + { + $autowire = new AutowireDatabase( + ...$attributeArguments, + client: 'default', + ); + + $definition = $autowire->buildDefinition( + value: $autowire->value, + type: Collection::class, + parameter: new ReflectionParameter( + static function (Database $database): void { + }, + 'database', + ), + ); + + $this->assertEquals($expectedOptions, $definition->getArgument(1)); } } diff --git a/tests/Unit/DependencyInjection/ConfigurationTest.php b/tests/Unit/DependencyInjection/ConfigurationTest.php index 9a46878..6cfd26c 100644 --- a/tests/Unit/DependencyInjection/ConfigurationTest.php +++ b/tests/Unit/DependencyInjection/ConfigurationTest.php @@ -38,12 +38,12 @@ public function testProcess(): void [ 'id' => 'default', 'uri' => 'mongodb://localhost:27017', - 'uriOptions' => ['readPreference' => 'primary'], + 'uri_options' => ['readPreference' => 'primary'], ], [ 'id' => 'secondary', 'uri' => 'mongodb://localhost:27018', - 'driverOptions' => ['serverApi' => new ServerApi((string) ServerApi::V1)], + 'driver_options' => ['serverApi' => new ServerApi((string) ServerApi::V1)], ], ], ], @@ -58,13 +58,13 @@ public function testProcess(): void $this->assertArrayHasKey('default', $clients); $this->assertSame('mongodb://localhost:27017', $clients['default']['uri']); - $this->assertSame(['readPreference' => 'primary'], $clients['default']['uriOptions']); - $this->assertSame([], $clients['default']['driverOptions']); + $this->assertSame(['readPreference' => 'primary'], $clients['default']['uri_options']); + $this->assertSame([], $clients['default']['driver_options']); $this->assertArrayHasKey('secondary', $clients); $this->assertSame('mongodb://localhost:27018', $clients['secondary']['uri']); - $this->assertSame([], $clients['secondary']['uriOptions']); - $this->assertEquals(['serverApi' => new ServerApi((string) ServerApi::V1)], $clients['secondary']['driverOptions']); + $this->assertSame([], $clients['secondary']['uri_options']); + $this->assertEquals(['serverApi' => new ServerApi((string) ServerApi::V1)], $clients['secondary']['driver_options']); } public function testProcessWithYamlFile(): void @@ -74,11 +74,11 @@ public function testProcessWithYamlFile(): void clients: default: uri: mongodb://localhost:27017 - uriOptions: + uri_options: readPreference: primary secondary: uri: mongodb://localhost:27018 - driverOptions: + driver_options: serverApi: v1 YAML); @@ -91,13 +91,13 @@ public function testProcessWithYamlFile(): void $this->assertArrayHasKey('default', $clients); $this->assertSame('mongodb://localhost:27017', $clients['default']['uri']); - $this->assertSame(['readPreference' => 'primary'], $clients['default']['uriOptions']); - $this->assertSame([], $clients['default']['driverOptions']); + $this->assertSame(['readPreference' => 'primary'], $clients['default']['uri_options']); + $this->assertSame([], $clients['default']['driver_options']); $this->assertArrayHasKey('secondary', $clients); $this->assertSame('mongodb://localhost:27018', $clients['secondary']['uri']); - $this->assertSame([], $clients['secondary']['uriOptions']); - $this->assertSame(['serverApi' => 'v1'], $clients['secondary']['driverOptions']); + $this->assertSame([], $clients['secondary']['uri_options']); + $this->assertSame(['serverApi' => 'v1'], $clients['secondary']['driver_options']); } public function testProcessWithYamlFileWithoutUriKey(): void diff --git a/tests/Unit/DependencyInjection/MongoDBExtensionTest.php b/tests/Unit/DependencyInjection/MongoDBExtensionTest.php index 4a94d4a..c0cb90f 100644 --- a/tests/Unit/DependencyInjection/MongoDBExtensionTest.php +++ b/tests/Unit/DependencyInjection/MongoDBExtensionTest.php @@ -75,12 +75,12 @@ public function testLoadWithMultipleClients(): void [ 'id' => 'default', 'uri' => 'mongodb://localhost:27017', - 'uriOptions' => ['readPreference' => 'primary'], + 'uri_options' => ['readPreference' => 'primary'], ], [ 'id' => 'secondary', 'uri' => 'mongodb://localhost:27018', - 'driverOptions' => ['serverApi' => new ServerApi((string) ServerApi::V1)], + 'driver_options' => ['serverApi' => new ServerApi((string) ServerApi::V1)], ], ], ],