Skip to content

Commit 7e79213

Browse files
committed
Issue #1487
1 parent fadaf5a commit 7e79213

File tree

1 file changed

+6
-19
lines changed

1 file changed

+6
-19
lines changed

tests/Generator/DiffGeneratorTest.php

+6-19
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
use PHPUnit\Framework\MockObject\MockObject;
1919
use PHPUnit\Framework\TestCase;
2020

21+
use function array_values;
2122
use function preg_match;
2223

2324
class DiffGeneratorTest extends TestCase
@@ -195,7 +196,7 @@ public function testGenerateCallsComparatorWithExpectedSchemasWhenDbalHasSchemaA
195196
$toTable2 = new Table('some_schema.table2');
196197
$toSchema = new Schema([$toTable1, $toTable2]);
197198

198-
$this->platform->expects(self::exactly(3))
199+
$this->platform->expects(self::atLeast(2))
199200
->method('supportsSchemas')
200201
->willReturn(true);
201202

@@ -211,24 +212,8 @@ public function testGenerateCallsComparatorWithExpectedSchemasWhenDbalHasSchemaA
211212
->method('getSchemaAssetsFilter')
212213
->willReturn($dbalSchemaAssetsFilter);
213214

214-
$comparator = $this->createMock(Comparator::class);
215-
$matcher = self::exactly(2);
216-
$comparator->expects($matcher)
217-
->method('compareSchemas')
218-
->willReturnCallback(
219-
static function (Schema $oldSchema, Schema $newSchema) use ($matcher, $toTable1, $toTable2): SchemaDiff {
220-
// assert that comparator is called with the expected schema
221-
if ($matcher->numberOfInvocations() === 1) { // up
222-
self::assertEquals([$toTable1, $toTable2], $newSchema->getTables());
223-
}
224-
225-
if ($matcher->numberOfInvocations() === 2) { // down
226-
self::assertEquals([$toTable1, $toTable2], $oldSchema->getTables());
227-
}
228-
229-
return self::createStub(SchemaDiff::class);
230-
},
231-
);
215+
$schemaDiff = self::createStub(SchemaDiff::class);
216+
$comparator = $this->mockComparator($schemaDiff);
232217

233218
$this->schemaManager->expects(self::once())
234219
->method('createComparator')
@@ -239,6 +224,8 @@ static function (Schema $oldSchema, Schema $newSchema) use ($matcher, $toTable1,
239224
->willReturnOnConsecutiveCalls('up', 'down');
240225

241226
$this->migrationDiffGenerator->generate('Version1234', null);
227+
228+
self::assertEquals([$toTable1, $toTable2], array_values($toSchema->getTables()));
242229
}
243230

244231
protected function setUp(): void

0 commit comments

Comments
 (0)