18
18
use PHPUnit \Framework \MockObject \MockObject ;
19
19
use PHPUnit \Framework \TestCase ;
20
20
21
+ use function array_values ;
21
22
use function preg_match ;
22
23
23
24
class DiffGeneratorTest extends TestCase
@@ -195,7 +196,7 @@ public function testGenerateCallsComparatorWithExpectedSchemasWhenDbalHasSchemaA
195
196
$ toTable2 = new Table ('some_schema.table2 ' );
196
197
$ toSchema = new Schema ([$ toTable1 , $ toTable2 ]);
197
198
198
- $ this ->platform ->expects (self ::exactly ( 3 ))
199
+ $ this ->platform ->expects (self ::atLeast ( 2 ))
199
200
->method ('supportsSchemas ' )
200
201
->willReturn (true );
201
202
@@ -211,24 +212,8 @@ public function testGenerateCallsComparatorWithExpectedSchemasWhenDbalHasSchemaA
211
212
->method ('getSchemaAssetsFilter ' )
212
213
->willReturn ($ dbalSchemaAssetsFilter );
213
214
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 );
232
217
233
218
$ this ->schemaManager ->expects (self ::once ())
234
219
->method ('createComparator ' )
@@ -239,6 +224,8 @@ static function (Schema $oldSchema, Schema $newSchema) use ($matcher, $toTable1,
239
224
->willReturnOnConsecutiveCalls ('up ' , 'down ' );
240
225
241
226
$ this ->migrationDiffGenerator ->generate ('Version1234 ' , null );
227
+
228
+ self ::assertEquals ([$ toTable1 , $ toTable2 ], array_values ($ toSchema ->getTables ()));
242
229
}
243
230
244
231
protected function setUp (): void
0 commit comments