10
10
use Doctrine \DBAL \Schema \Comparator ;
11
11
use Doctrine \DBAL \Schema \Schema ;
12
12
use Doctrine \DBAL \Schema \SchemaDiff ;
13
+ use Doctrine \DBAL \Schema \Sequence ;
13
14
use Doctrine \DBAL \Schema \Table ;
14
15
use Doctrine \Migrations \Generator \DiffGenerator ;
15
16
use Doctrine \Migrations \Generator \Generator ;
@@ -43,7 +44,7 @@ public function testGenerate(): void
43
44
$ this ->dbalConfiguration ->expects (self ::once ())
44
45
->method ('getSchemaAssetsFilter ' )
45
46
->willReturn (
46
- static fn ($ name ): bool => $ name === 'table_name1 ' ,
47
+ static fn ($ name ): bool => in_array ( $ name, [ 'table_name1 ' , ' table_name2_id_seq ' ], true ) ,
47
48
);
48
49
49
50
$ table1 = $ this ->createMock (Table::class);
@@ -61,10 +62,24 @@ public function testGenerate(): void
61
62
->method ('getName ' )
62
63
->willReturn ('schema.table_name3 ' );
63
64
65
+ $ sequence1 = $ this ->createMock (Sequence::class);
66
+ $ sequence1 ->expects (self ::once ())
67
+ ->method ('getName ' )
68
+ ->willReturn ('table_name1_id_seq ' );
69
+
70
+ $ sequence2 = $ this ->createMock (Sequence::class);
71
+ $ sequence2 ->expects (self ::once ())
72
+ ->method ('getName ' )
73
+ ->willReturn ('table_name2_id_seq ' );
74
+
64
75
$ toSchema ->expects (self ::once ())
65
76
->method ('getTables ' )
66
77
->willReturn ([$ table1 , $ table2 , $ table3 ]);
67
78
79
+ $ toSchema ->expects (self ::once ())
80
+ ->method ('getSequences ' )
81
+ ->willReturn ([$ sequence1 , $ sequence2 ]);
82
+
68
83
$ this ->emptySchemaProvider ->expects (self ::never ())
69
84
->method ('createSchema ' );
70
85
@@ -80,6 +95,10 @@ public function testGenerate(): void
80
95
->method ('dropTable ' )
81
96
->willReturnSelf ();
82
97
98
+ $ toSchema ->expects (self ::once ())
99
+ ->method ('dropSequence ' )
100
+ ->with ('table_name1_id_seq ' );
101
+
83
102
$ schemaDiff = self ::createStub (SchemaDiff::class);
84
103
85
104
$ this ->platform ->method ('getAlterSchemaSQL ' )->willReturnCallback (static function (): array {
0 commit comments