ComparatorTest.php 1.29 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
<?php

declare(strict_types=1);

namespace Doctrine\Tests\DBAL\Functional\Schema;

use Doctrine\DBAL\Schema\AbstractSchemaManager;
use Doctrine\DBAL\Schema\Comparator;
use Doctrine\DBAL\Schema\Table;
use Doctrine\Tests\DbalFunctionalTestCase;

class ComparatorTest extends DbalFunctionalTestCase
{
    /** @var AbstractSchemaManager */
    private $schemaManager;

    /** @var Comparator */
    private $comparator;

20
    protected function setUp(): void
21 22 23 24 25 26 27
    {
        parent::setUp();

        $this->schemaManager = $this->connection->getSchemaManager();
        $this->comparator    = new Comparator();
    }

28 29 30 31 32
    /**
     * @param mixed $value
     *
     * @dataProvider defaultValueProvider
     */
33
    public function testDefaultValueComparison(string $type, $value): void
34 35
    {
        $table = new Table('default_value');
36
        $table->addColumn('test', $type, ['default' => $value]);
37

38
        $this->schemaManager->dropAndCreateTable($table);
39 40 41 42 43

        $onlineTable = $this->schemaManager->listTableDetails('default_value');

        self::assertFalse($this->comparator->diffTable($table, $onlineTable));
    }
44 45 46 47

    /**
     * @return mixed[][]
     */
48
    public static function defaultValueProvider(): iterable
49 50 51 52 53 54
    {
        return [
            ['integer', 1],
            ['boolean', false],
        ];
    }
55
}