1111
1212namespace Symfony \Component \Lock \Tests \Store ;
1313
14+ use Doctrine \DBAL \Configuration ;
1415use Doctrine \DBAL \Connection ;
1516use Doctrine \DBAL \DriverManager ;
1617use Doctrine \DBAL \Exception \TableNotFoundException ;
1718use Doctrine \DBAL \Platforms \AbstractPlatform ;
19+ use Doctrine \DBAL \Schema \DefaultSchemaManagerFactory ;
20+ use Doctrine \ORM \ORMSetup ;
1821use Symfony \Component \Lock \Key ;
1922use Symfony \Component \Lock \PersistingStoreInterface ;
2023use Symfony \Component \Lock \Store \DoctrineDbalStore ;
@@ -36,7 +39,12 @@ public static function setUpBeforeClass(): void
3639 {
3740 self ::$ dbFile = tempnam (sys_get_temp_dir (), 'sf_sqlite_lock ' );
3841
39- $ store = new DoctrineDbalStore (DriverManager::getConnection (['driver ' => 'pdo_sqlite ' , 'path ' => self ::$ dbFile ]));
42+ $ config = class_exists (ORMSetup::class) ? ORMSetup::createConfiguration (true ) : new Configuration ();
43+ if (class_exists (DefaultSchemaManagerFactory::class)) {
44+ $ config ->setSchemaManagerFactory (new DefaultSchemaManagerFactory ());
45+ }
46+
47+ $ store = new DoctrineDbalStore (DriverManager::getConnection (['driver ' => 'pdo_sqlite ' , 'path ' => self ::$ dbFile ], $ config ));
4048 $ store ->createTable ();
4149 }
4250
@@ -52,7 +60,12 @@ protected function getClockDelay()
5260
5361 public function getStore (): PersistingStoreInterface
5462 {
55- return new DoctrineDbalStore (DriverManager::getConnection (['driver ' => 'pdo_sqlite ' , 'path ' => self ::$ dbFile ]));
63+ $ config = class_exists (ORMSetup::class) ? ORMSetup::createConfiguration (true ) : new Configuration ();
64+ if (class_exists (DefaultSchemaManagerFactory::class)) {
65+ $ config ->setSchemaManagerFactory (new DefaultSchemaManagerFactory ());
66+ }
67+
68+ return new DoctrineDbalStore (DriverManager::getConnection (['driver ' => 'pdo_sqlite ' , 'path ' => self ::$ dbFile ], $ config ));
5669 }
5770
5871 public function testAbortAfterExpiration ()
0 commit comments