|
| 1 | +<?php |
| 2 | + |
| 3 | +declare(strict_types=1); |
| 4 | + |
| 5 | +namespace Doctrine\DBAL\Tests\Functional\Schema\Oracle; |
| 6 | + |
| 7 | +use Doctrine\DBAL\Platforms\OraclePlatform; |
| 8 | +use Doctrine\DBAL\Schema\AbstractSchemaManager; |
| 9 | +use Doctrine\DBAL\Schema\Comparator; |
| 10 | +use Doctrine\DBAL\Schema\Table; |
| 11 | +use Doctrine\DBAL\Tests\Functional\Schema\ComparatorTestUtils; |
| 12 | +use Doctrine\DBAL\Tests\FunctionalTestCase; |
| 13 | +use Doctrine\DBAL\Types\Types; |
| 14 | + |
| 15 | +final class ComparatorTest extends FunctionalTestCase |
| 16 | +{ |
| 17 | + private AbstractSchemaManager $schemaManager; |
| 18 | + |
| 19 | + private Comparator $comparator; |
| 20 | + |
| 21 | + protected function setUp(): void |
| 22 | + { |
| 23 | + if (! $this->connection->getDatabasePlatform() instanceof OraclePlatform) { |
| 24 | + self::markTestSkipped('This test covers Oracle-specific schema comparison scenarios.'); |
| 25 | + } |
| 26 | + |
| 27 | + $this->schemaManager = $this->connection->createSchemaManager(); |
| 28 | + $this->comparator = $this->schemaManager->createComparator(); |
| 29 | + } |
| 30 | + |
| 31 | + /** |
| 32 | + * Oracle does not support fixed length binary columns. The DBAL will map the {@see Types::BINARY} type |
| 33 | + * to the variable-length RAW column type regardless of the "fixed" attribute. |
| 34 | + * |
| 35 | + * There should not be a diff when comparing a variable-length and a fixed-length column |
| 36 | + * that are otherwise the same. |
| 37 | + * |
| 38 | + * @see OraclePlatform::getBinaryTypeDeclarationSQLSnippet() |
| 39 | + */ |
| 40 | + public function testChangeBinaryColumnFixed(): void |
| 41 | + { |
| 42 | + $table = new Table('comparator_test'); |
| 43 | + $column = $table->addColumn('id', Types::BINARY, [ |
| 44 | + 'length' => 32, |
| 45 | + 'fixed' => true, |
| 46 | + ]); |
| 47 | + $this->dropAndCreateTable($table); |
| 48 | + |
| 49 | + $column->setFixed(false); |
| 50 | + |
| 51 | + self::assertNull(ComparatorTestUtils::diffFromActualToDesiredTable( |
| 52 | + $this->schemaManager, |
| 53 | + $this->comparator, |
| 54 | + $table |
| 55 | + )); |
| 56 | + |
| 57 | + self::assertNull(ComparatorTestUtils::diffFromDesiredToActualTable( |
| 58 | + $this->schemaManager, |
| 59 | + $this->comparator, |
| 60 | + $table |
| 61 | + )); |
| 62 | + } |
| 63 | +} |
0 commit comments