Skip to content

Commit c968672

Browse files
committed
fix Doctrine deprecations
1 parent d8364cf commit c968672

File tree

1 file changed

+15
-2
lines changed

1 file changed

+15
-2
lines changed

Tests/Store/DoctrineDbalStoreTest.php

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,13 @@
1111

1212
namespace Symfony\Component\Lock\Tests\Store;
1313

14+
use Doctrine\DBAL\Configuration;
1415
use Doctrine\DBAL\Connection;
1516
use Doctrine\DBAL\DriverManager;
1617
use Doctrine\DBAL\Exception\TableNotFoundException;
1718
use Doctrine\DBAL\Platforms\AbstractPlatform;
19+
use Doctrine\DBAL\Schema\DefaultSchemaManagerFactory;
20+
use Doctrine\ORM\ORMSetup;
1821
use Symfony\Component\Lock\Key;
1922
use Symfony\Component\Lock\PersistingStoreInterface;
2023
use 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

Comments
 (0)