@@ -320,24 +320,17 @@ public function testLoadSimpleSingleConnection(): void
320320
321321 $ definition = $ container ->getDefinition ('doctrine.dbal.default_connection ' );
322322
323- $ this ->assertDICConstructorArguments ($ definition , [
324- [
325- 'dbname ' => 'db ' ,
326- 'host ' => 'localhost ' ,
327- 'port ' => null ,
328- 'user ' => 'root ' ,
329- 'password ' => null ,
330- 'driver ' => 'pdo_mysql ' ,
331- 'driverOptions ' => [],
332- 'defaultTableOptions ' => [],
333- 'idle_connection_ttl ' => 600 ,
334- ],
335- new Reference ('doctrine.dbal.default_connection.configuration ' ),
336- method_exists (Connection::class, 'getEventManager ' )
337- ? new Reference ('doctrine.dbal.default_connection.event_manager ' )
338- : null ,
339- [],
340- ]);
323+ $ this ->assertDICConstructorArguments ($ definition , $ this ->getFactoryArguments ([
324+ 'dbname ' => 'db ' ,
325+ 'host ' => 'localhost ' ,
326+ 'port ' => null ,
327+ 'user ' => 'root ' ,
328+ 'password ' => null ,
329+ 'driver ' => 'pdo_mysql ' ,
330+ 'driverOptions ' => [],
331+ 'defaultTableOptions ' => [],
332+ 'idle_connection_ttl ' => 600 ,
333+ ]));
341334
342335 $ definition = $ container ->getDefinition ('doctrine.orm.default_entity_manager ' );
343336 $ this ->assertEquals ('%doctrine.orm.entity_manager.class% ' , $ definition ->getClass ());
@@ -361,8 +354,9 @@ public function testLoadSimpleSingleConnectionWithoutDbName(): void
361354
362355 $ container = $ this ->loadContainer ('orm_service_simple_single_entity_manager_without_dbname ' );
363356
364- $ this ->assertDICConstructorArguments ($ container ->getDefinition ('doctrine.dbal.default_connection ' ), [
365- [
357+ $ this ->assertDICConstructorArguments (
358+ $ container ->getDefinition ('doctrine.dbal.default_connection ' ),
359+ $ this ->getFactoryArguments ([
366360 'host ' => 'localhost ' ,
367361 'port ' => null ,
368362 'user ' => 'root ' ,
@@ -371,13 +365,8 @@ public function testLoadSimpleSingleConnectionWithoutDbName(): void
371365 'driverOptions ' => [],
372366 'defaultTableOptions ' => [],
373367 'idle_connection_ttl ' => 600 ,
374- ],
375- new Reference ('doctrine.dbal.default_connection.configuration ' ),
376- method_exists (Connection::class, 'getEventManager ' )
377- ? new Reference ('doctrine.dbal.default_connection.event_manager ' )
378- : null ,
379- [],
380- ]);
368+ ]),
369+ );
381370
382371 $ definition = $ container ->getDefinition ('doctrine.orm.default_entity_manager ' );
383372 $ this ->assertEquals ('%doctrine.orm.entity_manager.class% ' , $ definition ->getClass ());
@@ -399,25 +388,18 @@ public function testLoadSingleConnection(): void
399388
400389 $ definition = $ container ->getDefinition ('doctrine.dbal.default_connection ' );
401390
402- $ this ->assertDICConstructorArguments ($ definition , [
403- [
404- 'host ' => 'localhost ' ,
405- 'driver ' => 'pdo_sqlite ' ,
406- 'driverOptions ' => [],
407- 'user ' => 'sqlite_user ' ,
408- 'port ' => null ,
409- 'password ' => 'sqlite_s3cr3t ' ,
410- 'dbname ' => 'sqlite_db ' ,
411- 'memory ' => true ,
412- 'defaultTableOptions ' => [],
413- 'idle_connection_ttl ' => 600 ,
414- ],
415- new Reference ('doctrine.dbal.default_connection.configuration ' ),
416- method_exists (Connection::class, 'getEventManager ' )
417- ? new Reference ('doctrine.dbal.default_connection.event_manager ' )
418- : null ,
419- [],
420- ]);
391+ $ this ->assertDICConstructorArguments ($ definition , $ this ->getFactoryArguments ([
392+ 'host ' => 'localhost ' ,
393+ 'driver ' => 'pdo_sqlite ' ,
394+ 'driverOptions ' => [],
395+ 'user ' => 'sqlite_user ' ,
396+ 'port ' => null ,
397+ 'password ' => 'sqlite_s3cr3t ' ,
398+ 'dbname ' => 'sqlite_db ' ,
399+ 'memory ' => true ,
400+ 'defaultTableOptions ' => [],
401+ 'idle_connection_ttl ' => 600 ,
402+ ]));
421403
422404 $ definition = $ container ->getDefinition ('doctrine.orm.default_entity_manager ' );
423405 $ this ->assertEquals ('%doctrine.orm.entity_manager.class% ' , $ definition ->getClass ());
@@ -1594,6 +1576,26 @@ private function compileContainer(ContainerBuilder $container): void
15941576 $ passConfig ->setRemovingPasses ([]);
15951577 $ container ->compile ();
15961578 }
1579+
1580+ /**
1581+ * @param array<string, mixed> $params
1582+ *
1583+ * @return list<mixed> The expected arguments to the connection factory
1584+ */
1585+ private function getFactoryArguments (array $ params ): array
1586+ {
1587+ $ args = [
1588+ $ params ,
1589+ new Reference ('doctrine.dbal.default_connection.configuration ' ),
1590+ ];
1591+ if (method_exists (Connection::class, 'getEventManager ' )) {
1592+ $ args [] = new Reference ('doctrine.dbal.default_connection.event_manager ' );
1593+ }
1594+
1595+ $ args [] = [];
1596+
1597+ return $ args ;
1598+ }
15971599}
15981600
15991601class DummySchemaAssetsFilter
0 commit comments