From a8f939aacd88fc3e0aea007c8b1d13845f99f54e Mon Sep 17 00:00:00 2001 From: Sergei Morozov Date: Sat, 3 Sep 2022 12:59:40 -0700 Subject: [PATCH] Make internal Comparator methods protected --- src/Schema/Comparator.php | 13 +++--------- tests/Schema/ComparatorTest.php | 26 ----------------------- tests/Schema/ForeignKeyConstraintTest.php | 8 +++++++ 3 files changed, 11 insertions(+), 36 deletions(-) diff --git a/src/Schema/Comparator.php b/src/Schema/Comparator.php index 6ec0f3d1c73..f7db444c341 100644 --- a/src/Schema/Comparator.php +++ b/src/Schema/Comparator.php @@ -382,10 +382,7 @@ private function detectIndexRenamings(TableDiff $tableDifferences): void } } - /** - * @internal The method should be only used from within the {@see Comparator} class hierarchy. - */ - public function diffForeignKey(ForeignKeyConstraint $key1, ForeignKeyConstraint $key2): bool + protected function diffForeignKey(ForeignKeyConstraint $key1, ForeignKeyConstraint $key2): bool { if ( array_map('strtolower', $key1->getUnquotedLocalColumns()) @@ -415,11 +412,9 @@ public function diffForeignKey(ForeignKeyConstraint $key1, ForeignKeyConstraint /** * Compares the definitions of the given columns * - * @internal The method should be only used from within the {@see Comparator} class hierarchy. - * * @throws Exception */ - public function columnsEqual(Column $column1, Column $column2): bool + protected function columnsEqual(Column $column1, Column $column2): bool { return $this->platform->columnsEqual($column1, $column2); } @@ -522,10 +517,8 @@ public function diffColumn(Column $column1, Column $column2): array * * Compares $index1 with $index2 and returns $index2 if there are any * differences or false in case there are no differences. - * - * @internal The method should be only used from within the {@see Comparator} class hierarchy. */ - public function diffIndex(Index $index1, Index $index2): bool + protected function diffIndex(Index $index1, Index $index2): bool { return ! ($index1->isFullfilledBy($index2) && $index2->isFullfilledBy($index1)); } diff --git a/tests/Schema/ComparatorTest.php b/tests/Schema/ComparatorTest.php index b77372a49a0..d11b75f9eec 100644 --- a/tests/Schema/ComparatorTest.php +++ b/tests/Schema/ComparatorTest.php @@ -662,22 +662,6 @@ public function testCompareForeignKeyBasedOnPropertiesNotName(): void self::assertNull($tableDiff); } - public function testCompareForeignKeyRestrictNoActionAreTheSame(): void - { - $fk1 = new ForeignKeyConstraint(['foo'], 'bar', ['baz'], 'fk1', ['onDelete' => 'NO ACTION']); - $fk2 = new ForeignKeyConstraint(['foo'], 'bar', ['baz'], 'fk1', ['onDelete' => 'RESTRICT']); - - self::assertFalse($this->comparator->diffForeignKey($fk1, $fk2)); - } - - public function testCompareForeignKeyNamesUnqualifiedAsNoSchemaInformationIsAvailable(): void - { - $fk1 = new ForeignKeyConstraint(['foo'], 'foo.bar', ['baz'], 'fk1'); - $fk2 = new ForeignKeyConstraint(['foo'], 'baz.bar', ['baz'], 'fk1'); - - self::assertFalse($this->comparator->diffForeignKey($fk1, $fk2)); - } - public function testDetectRenameColumn(): void { $tableA = new Table('foo'); @@ -1032,16 +1016,6 @@ public function testCompareChangedBinaryColumn(): void self::assertEquals($expected, $this->comparator->compareSchemas($oldSchema, $newSchema)); } - public function testCompareQuotedAndUnquotedForeignKeyColumns(): void - { - $fk1 = new ForeignKeyConstraint(['foo'], 'bar', ['baz'], 'fk1', ['onDelete' => 'NO ACTION']); - $fk2 = new ForeignKeyConstraint(['`foo`'], 'bar', ['`baz`'], 'fk1', ['onDelete' => 'NO ACTION']); - - $diff = $this->comparator->diffForeignKey($fk1, $fk2); - - self::assertFalse($diff); - } - public function assertSchemaTableChangeCount( SchemaDiff $diff, int $newTableCount = 0, diff --git a/tests/Schema/ForeignKeyConstraintTest.php b/tests/Schema/ForeignKeyConstraintTest.php index d867d7473db..f703e63f4b3 100644 --- a/tests/Schema/ForeignKeyConstraintTest.php +++ b/tests/Schema/ForeignKeyConstraintTest.php @@ -74,4 +74,12 @@ public static function getUnqualifiedForeignTableNameData(): iterable ['foreign_table', 'foreign_table'], ]; } + + public function testCompareRestrictAndNoActionAreTheSame(): void + { + $fk1 = new ForeignKeyConstraint(['foo'], 'bar', ['baz'], 'fk1', ['onDelete' => 'NO ACTION']); + $fk2 = new ForeignKeyConstraint(['foo'], 'bar', ['baz'], 'fk1', ['onDelete' => 'RESTRICT']); + + self::assertSame($fk1->onDelete(), $fk2->onDelete()); + } }