forked from doctrine/dbal
/
ComparatorTest.php
58 lines (47 loc) · 1.77 KB
/
ComparatorTest.php
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
<?php
declare(strict_types=1);
namespace Doctrine\DBAL\Tests\Functional\Schema;
use Doctrine\DBAL\Platforms\AbstractMySQLPlatform;
use Doctrine\DBAL\Platforms\MariaDBPlatform;
use Doctrine\DBAL\Schema\AbstractSchemaManager;
use Doctrine\DBAL\Schema\Table;
use Doctrine\DBAL\Tests\FunctionalTestCase;
use Doctrine\DBAL\Types\Types;
class ComparatorTest extends FunctionalTestCase
{
private AbstractSchemaManager $schemaManager;
protected function setUp(): void
{
$this->schemaManager = $this->connection->createSchemaManager();
}
/** @dataProvider defaultValueProvider */
public function testDefaultValueComparison(string $type, mixed $value): void
{
$platform = $this->connection->getDatabasePlatform();
if (
$type === Types::TEXT && $platform instanceof AbstractMySQLPlatform
&& ! $platform instanceof MariaDBPlatform
) {
// See https://dev.mysql.com/doc/relnotes/mysql/8.0/en/news-8-0-13.html#mysqld-8-0-13-data-types
self::markTestSkipped('Oracle MySQL does not support default values on TEXT/BLOB columns until 8.0.13.');
}
$table = new Table('default_value');
$table->addColumn('test', $type, ['default' => $value]);
$this->dropAndCreateTable($table);
$onlineTable = $this->schemaManager->introspectTable('default_value');
self::assertTrue(
$this->schemaManager->createComparator()
->compareTables($table, $onlineTable)
->isEmpty(),
);
}
/** @return iterable<mixed[]> */
public static function defaultValueProvider(): iterable
{
return [
[Types::INTEGER, 1],
[Types::BOOLEAN, false],
[Types::TEXT, 'Doctrine'],
];
}
}