From 7e79213cf0fe034c4d5ca6e3647a817f314b365a Mon Sep 17 00:00:00 2001 From: Cristi Contiu Date: Fri, 28 Feb 2025 00:42:07 +0200 Subject: [PATCH] Issue #1487 --- tests/Generator/DiffGeneratorTest.php | 25 ++++++------------------- 1 file changed, 6 insertions(+), 19 deletions(-) diff --git a/tests/Generator/DiffGeneratorTest.php b/tests/Generator/DiffGeneratorTest.php index 3b4a597bf..ba255ecc6 100644 --- a/tests/Generator/DiffGeneratorTest.php +++ b/tests/Generator/DiffGeneratorTest.php @@ -18,6 +18,7 @@ use PHPUnit\Framework\MockObject\MockObject; use PHPUnit\Framework\TestCase; +use function array_values; use function preg_match; class DiffGeneratorTest extends TestCase @@ -195,7 +196,7 @@ public function testGenerateCallsComparatorWithExpectedSchemasWhenDbalHasSchemaA $toTable2 = new Table('some_schema.table2'); $toSchema = new Schema([$toTable1, $toTable2]); - $this->platform->expects(self::exactly(3)) + $this->platform->expects(self::atLeast(2)) ->method('supportsSchemas') ->willReturn(true); @@ -211,24 +212,8 @@ public function testGenerateCallsComparatorWithExpectedSchemasWhenDbalHasSchemaA ->method('getSchemaAssetsFilter') ->willReturn($dbalSchemaAssetsFilter); - $comparator = $this->createMock(Comparator::class); - $matcher = self::exactly(2); - $comparator->expects($matcher) - ->method('compareSchemas') - ->willReturnCallback( - static function (Schema $oldSchema, Schema $newSchema) use ($matcher, $toTable1, $toTable2): SchemaDiff { - // assert that comparator is called with the expected schema - if ($matcher->numberOfInvocations() === 1) { // up - self::assertEquals([$toTable1, $toTable2], $newSchema->getTables()); - } - - if ($matcher->numberOfInvocations() === 2) { // down - self::assertEquals([$toTable1, $toTable2], $oldSchema->getTables()); - } - - return self::createStub(SchemaDiff::class); - }, - ); + $schemaDiff = self::createStub(SchemaDiff::class); + $comparator = $this->mockComparator($schemaDiff); $this->schemaManager->expects(self::once()) ->method('createComparator') @@ -239,6 +224,8 @@ static function (Schema $oldSchema, Schema $newSchema) use ($matcher, $toTable1, ->willReturnOnConsecutiveCalls('up', 'down'); $this->migrationDiffGenerator->generate('Version1234', null); + + self::assertEquals([$toTable1, $toTable2], array_values($toSchema->getTables())); } protected function setUp(): void