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 ;
@@ -55,7 +56,7 @@ public function testGenerate(): void
55
56
->method ('getSchemaAssetsFilter ' )
56
57
->willReturn (
57
58
static function ($ name ): bool {
58
- return $ name === 'table_name1 ' ;
59
+ return in_array ( $ name, [ 'table_name1 ' , ' table_name2_id_seq ' ], true ) ;
59
60
},
60
61
);
61
62
@@ -74,10 +75,24 @@ static function ($name): bool {
74
75
->method ('getName ' )
75
76
->willReturn ('schema.table_name3 ' );
76
77
78
+ $ sequence1 = $ this ->createMock (Sequence::class);
79
+ $ sequence1 ->expects (self ::once ())
80
+ ->method ('getName ' )
81
+ ->willReturn ('table_name1_id_seq ' );
82
+
83
+ $ sequence2 = $ this ->createMock (Sequence::class);
84
+ $ sequence2 ->expects (self ::once ())
85
+ ->method ('getName ' )
86
+ ->willReturn ('table_name2_id_seq ' );
87
+
77
88
$ toSchema ->expects (self ::once ())
78
89
->method ('getTables ' )
79
90
->willReturn ([$ table1 , $ table2 , $ table3 ]);
80
91
92
+ $ toSchema ->expects (self ::once ())
93
+ ->method ('getSequences ' )
94
+ ->willReturn ([$ sequence1 , $ sequence2 ]);
95
+
81
96
$ this ->emptySchemaProvider ->expects (self ::never ())
82
97
->method ('createSchema ' );
83
98
@@ -93,6 +108,10 @@ static function ($name): bool {
93
108
->method ('dropTable ' )
94
109
->willReturnOnConsecutiveCalls ('schema.table_name2 ' , 'schema.table_name3 ' );
95
110
111
+ $ toSchema ->expects (self ::once ())
112
+ ->method ('dropSequence ' )
113
+ ->with ('table_name1_id_seq ' );
114
+
96
115
$ schemaDiff = self ::createStub (SchemaDiff::class);
97
116
98
117
$ this ->platform ->method ('getAlterSchemaSQL ' )->willReturnCallback (static function (): array {
0 commit comments