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 ;
18
19
use PHPUnit \Framework \MockObject \MockObject ;
19
20
use PHPUnit \Framework \TestCase ;
20
21
22
+ use function in_array ;
23
+
21
24
class DiffGeneratorTest extends TestCase
22
25
{
23
26
private DBALConfiguration &MockObject $ dbalConfiguration ;
@@ -43,7 +46,7 @@ public function testGenerate(): void
43
46
$ this ->dbalConfiguration ->expects (self ::once ())
44
47
->method ('getSchemaAssetsFilter ' )
45
48
->willReturn (
46
- static fn ($ name ): bool => $ name === 'table_name1 ' ,
49
+ static fn ($ name ): bool => in_array ( $ name, [ 'table_name1 ' , ' table_name2_id_seq ' ], true ) ,
47
50
);
48
51
49
52
$ table1 = $ this ->createMock (Table::class);
@@ -61,10 +64,24 @@ public function testGenerate(): void
61
64
->method ('getName ' )
62
65
->willReturn ('schema.table_name3 ' );
63
66
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
+
64
77
$ toSchema ->expects (self ::once ())
65
78
->method ('getTables ' )
66
79
->willReturn ([$ table1 , $ table2 , $ table3 ]);
67
80
81
+ $ toSchema ->expects (self ::once ())
82
+ ->method ('getSequences ' )
83
+ ->willReturn ([$ sequence1 , $ sequence2 ]);
84
+
68
85
$ this ->emptySchemaProvider ->expects (self ::never ())
69
86
->method ('createSchema ' );
70
87
@@ -80,6 +97,10 @@ public function testGenerate(): void
80
97
->method ('dropTable ' )
81
98
->willReturnSelf ();
82
99
100
+ $ toSchema ->expects (self ::once ())
101
+ ->method ('dropSequence ' )
102
+ ->with ('table_name1_id_seq ' );
103
+
83
104
$ schemaDiff = self ::createStub (SchemaDiff::class);
84
105
85
106
$ this ->platform ->method ('getAlterSchemaSQL ' )->willReturnCallback (static function (): array {
0 commit comments