File tree Expand file tree Collapse file tree 1 file changed +8
-1
lines changed Expand file tree Collapse file tree 1 file changed +8
-1
lines changed Original file line number Diff line number Diff line change 99namespace Ibexa \Tests \Core \Persistence ;
1010
1111use Doctrine \Common \EventManager ;
12+ use Doctrine \DBAL \Configuration ;
1213use Doctrine \DBAL \Connection ;
14+ use Doctrine \DBAL \Driver \AbstractSQLiteDriver \Middleware \EnableForeignKeys ;
1315use Doctrine \DBAL \DriverManager ;
16+ use Doctrine \DBAL \Platforms \SqlitePlatform ;
1417
1518/**
1619 * Database connection factory for integration tests.
@@ -70,15 +73,19 @@ public function createConnection(string $databaseURL): Connection
7073 // set DbPlatform based on database url scheme
7174 $ scheme = parse_url ($ databaseURL , PHP_URL_SCHEME );
7275 $ driverName = 'pdo_ ' . $ scheme ;
76+ $ config = new Configuration ();
7377 if (isset ($ this ->databasePlatforms [$ driverName ])) {
7478 $ params ['platform ' ] = $ this ->databasePlatforms [$ driverName ];
7579 // add predefined event subscribers only for the relevant connection
7680 $ params ['platform ' ]->addEventSubscribers ($ this ->eventManager );
81+ if ($ params ['platform ' ] instanceof SqlitePlatform) {
82+ $ config ->setMiddlewares ([new EnableForeignKeys ()]);
83+ }
7784 }
7885
7986 self ::$ connectionPool [$ databaseURL ] = DriverManager::getConnection (
8087 $ params ,
81- null ,
88+ $ config ,
8289 $ this ->eventManager
8390 );
8491 self ::$ connectionPool [$ databaseURL ]->setNestTransactionsWithSavepoints (true );
You can’t perform that action at this time.
0 commit comments