1010use Doctrine \DBAL \Schema \Comparator ;
1111use Doctrine \DBAL \Schema \Schema ;
1212use Doctrine \DBAL \Schema \SchemaDiff ;
13+ use Doctrine \DBAL \Schema \Sequence ;
1314use Doctrine \DBAL \Schema \Table ;
1415use Doctrine \Migrations \Generator \DiffGenerator ;
1516use Doctrine \Migrations \Generator \Generator ;
1819use PHPUnit \Framework \MockObject \MockObject ;
1920use PHPUnit \Framework \TestCase ;
2021
22+ use function in_array ;
23+
2124class DiffGeneratorTest extends TestCase
2225{
2326 private DBALConfiguration &MockObject $ dbalConfiguration ;
@@ -43,7 +46,7 @@ public function testGenerate(): void
4346 $ this ->dbalConfiguration ->expects (self ::once ())
4447 ->method ('getSchemaAssetsFilter ' )
4548 ->willReturn (
46- static fn ($ name ): bool => $ name === 'table_name1 ' ,
49+ static fn ($ name ): bool => in_array ( $ name, [ 'table_name1 ' , ' table_name2_id_seq ' ], true ) ,
4750 );
4851
4952 $ table1 = $ this ->createMock (Table::class);
@@ -61,10 +64,24 @@ public function testGenerate(): void
6164 ->method ('getName ' )
6265 ->willReturn ('schema.table_name3 ' );
6366
67+ $ sequence1 = $ this ->createMock (Sequence::class);
68+ $ sequence1 ->expects (self ::once ())
69+ ->method ('getName ' )
70+ ->willReturn ('table_name1_id_seq ' );
71+
72+ $ sequence2 = $ this ->createMock (Sequence::class);
73+ $ sequence2 ->expects (self ::once ())
74+ ->method ('getName ' )
75+ ->willReturn ('table_name2_id_seq ' );
76+
6477 $ toSchema ->expects (self ::once ())
6578 ->method ('getTables ' )
6679 ->willReturn ([$ table1 , $ table2 , $ table3 ]);
6780
81+ $ toSchema ->expects (self ::once ())
82+ ->method ('getSequences ' )
83+ ->willReturn ([$ sequence1 , $ sequence2 ]);
84+
6885 $ this ->emptySchemaProvider ->expects (self ::never ())
6986 ->method ('createSchema ' );
7087
@@ -80,6 +97,10 @@ public function testGenerate(): void
8097 ->method ('dropTable ' )
8198 ->willReturnSelf ();
8299
100+ $ toSchema ->expects (self ::once ())
101+ ->method ('dropSequence ' )
102+ ->with ('table_name1_id_seq ' );
103+
83104 $ schemaDiff = self ::createStub (SchemaDiff::class);
84105
85106 $ this ->platform ->method ('getAlterSchemaSQL ' )->willReturnCallback (static function (): array {
0 commit comments