forked from doctrine/dbal
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathVersionAwarePlatformDriverTest.php
More file actions
78 lines (67 loc) · 2.78 KB
/
VersionAwarePlatformDriverTest.php
File metadata and controls
78 lines (67 loc) · 2.78 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
<?php
declare(strict_types=1);
namespace Doctrine\DBAL\Tests\Driver;
use Doctrine\DBAL\Connection\StaticServerVersionProvider;
use Doctrine\DBAL\Driver;
use Doctrine\DBAL\Platforms\AbstractPlatform;
use Doctrine\DBAL\Platforms\MariaDB1010Platform;
use Doctrine\DBAL\Platforms\MariaDBPlatform;
use Doctrine\DBAL\Platforms\MySQLPlatform;
use Doctrine\DBAL\Platforms\PostgreSQLPlatform;
use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\TestCase;
class VersionAwarePlatformDriverTest extends TestCase
{
#[DataProvider('mySQLVersionProvider')]
public function testMySQLi(string $version, string $expectedClass): void
{
$this->assertDriverInstantiatesDatabasePlatform(new Driver\Mysqli\Driver(), $version, $expectedClass);
}
#[DataProvider('mySQLVersionProvider')]
public function testPDOMySQL(string $version, string $expectedClass): void
{
$this->assertDriverInstantiatesDatabasePlatform(new Driver\PDO\MySQL\Driver(), $version, $expectedClass);
}
/** @return array<array{string, class-string<AbstractPlatform>}> */
public static function mySQLVersionProvider(): array
{
return [
['8.0.11', MySQLPlatform::class],
['5.5.40-MariaDB-1~wheezy', MariaDBPlatform::class],
['5.5.5-MariaDB-10.2.8+maria~xenial-log', MariaDBPlatform::class],
['10.2.8-MariaDB-10.2.8+maria~xenial-log', MariaDBPlatform::class],
['10.6.0-MariaDB-1~lenny-log', MariaDBPlatform::class],
['10.9.3-MariaDB-1~lenny-log', MariaDBPlatform::class],
['11.0.2-MariaDB-1:11.0.2+maria~ubu2204', MariaDB1010Platform::class],
];
}
#[DataProvider('postgreSQLVersionProvider')]
public function testPgSQL(string $version, string $expectedClass): void
{
$this->assertDriverInstantiatesDatabasePlatform(new Driver\PgSQL\Driver(), $version, $expectedClass);
}
#[DataProvider('postgreSQLVersionProvider')]
public function testPDOPgSQL(string $version, string $expectedClass): void
{
$this->assertDriverInstantiatesDatabasePlatform(new Driver\PDO\PgSQL\Driver(), $version, $expectedClass);
}
/** @return array<array{string, class-string<AbstractPlatform>}> */
public static function postgreSQLVersionProvider(): array
{
return [
['12.0', PostgreSQLPlatform::class],
['13.16', PostgreSQLPlatform::class],
['16.4', PostgreSQLPlatform::class],
];
}
private function assertDriverInstantiatesDatabasePlatform(
Driver $driver,
string $version,
string $expectedClass,
): void {
$platform = $driver->getDatabasePlatform(
new StaticServerVersionProvider($version),
);
self::assertSame($expectedClass, $platform::class);
}
}