Skip to content

Commit

Permalink
Remove support of doctrine/dbal < 2.10
Browse files Browse the repository at this point in the history
  • Loading branch information
franmomu committed Aug 31, 2023
1 parent 8c3ab2a commit da358b2
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 9 deletions.
8 changes: 2 additions & 6 deletions Storage/DoctrineStorage.php
Original file line number Diff line number Diff line change
Expand Up @@ -150,13 +150,9 @@ private function tableExists() {
}

private function createTable() {
// TODO remove as soon as Doctrine DBAL >= 3.0 is required
$stringType = defined('Doctrine\DBAL\Types\Types::STRING') ? Types::STRING : Type::STRING;
$arrayType = defined('Doctrine\DBAL\Types\Types::ARRAY') ? Types::ARRAY : Type::TARRAY;

$table = new Table(self::TABLE, [
new Column($this->keyColumn, Type::getType($stringType)),
new Column($this->valueColumn, Type::getType($arrayType)),
new Column($this->keyColumn, Type::getType(Types::STRING), ['length' => 255]),
new Column($this->valueColumn, Type::getType(Types::ARRAY), ['length' => 255]),
]);

$table->setPrimaryKey([$this->keyColumn]);
Expand Down
15 changes: 12 additions & 3 deletions Tests/Storage/DoctrineStorageTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
use Doctrine\DBAL\Connection;
use Doctrine\DBAL\DriverManager;
use Doctrine\DBAL\Schema\DefaultSchemaManagerFactory;
use Doctrine\DBAL\Tools\DsnParser;

/**
* @group unit
Expand Down Expand Up @@ -40,9 +41,17 @@ protected function getStorageImplementation() {
$this->markTestSkipped('Environment variable DB_DSN is not set.');
}

$this->conn = DriverManager::getConnection([
'url' => $_ENV['DB_DSN'],
], $configuration);
$dsn = $_ENV['DB_DSN'];
// TODO use DsnParser as soon as DBAL >= 3.6 is required
$params = class_exists(DsnParser::class)
? (new DsnParser([
'mysql' => 'pdo_mysql',
'pgsql' => 'pdo_pgsql',
'sqlite' => 'pdo_sqlite',
]))->parse($dsn)
: ['url' => $dsn];

$this->conn = DriverManager::getConnection($params, $configuration);

$generator = $this->createMock(StorageKeyGeneratorInterface::class);

Expand Down
4 changes: 4 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
"craue/translations-tests": "^1.1",
"doctrine/collections": "^1.8 || ^2.1",
"doctrine/common": "^2.9 || ^3.0",
"doctrine/dbal": "^2.10 || ^3.0",
"doctrine/doctrine-bundle": "^1.10 || ^2.0",
"phpstan/extension-installer": "^1.1",
"phpstan/phpstan": "^1.10",
Expand All @@ -52,6 +53,9 @@
"symfony/security-bundle": "^4.4 || ^5.4 || ^6.3",
"symfony/twig-bundle": "^4.4 || ^5.4 || ^6.3"
},
"conflict": {
"doctrine/dbal": "<2.10"
},
"minimum-stability": "stable",
"autoload": {
"psr-4": {
Expand Down

0 comments on commit da358b2

Please sign in to comment.