ComparatorTest.php 1.29 KB
Newer Older
1 2 3 4
<?php

declare(strict_types=1);

5
namespace Doctrine\DBAL\Tests\Functional\Schema;
6 7 8 9

use Doctrine\DBAL\Schema\AbstractSchemaManager;
use Doctrine\DBAL\Schema\Comparator;
use Doctrine\DBAL\Schema\Table;
10
use Doctrine\DBAL\Tests\FunctionalTestCase;
11

12
class ComparatorTest extends FunctionalTestCase
13 14 15 16 17 18 19
{
    /** @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 33
    /**
     * @param mixed $value
     *
     * @dataProvider defaultValueProvider
     */
    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

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

42
        self::assertNull($this->comparator->diffTable($table, $onlineTable));
43
    }
44 45 46 47 48 49 50 51 52 53 54

    /**
     * @return mixed[][]
     */
    public static function defaultValueProvider() : iterable
    {
        return [
            ['integer', 1],
            ['boolean', false],
        ];
    }
55
}