1212
1313namespace UserFrosting \Sprinkle \Core \Tests \Unit \Bakery ;
1414
15- use Doctrine \DBAL \Schema \AbstractSchemaManager ;
1615use Illuminate \Database \Capsule \Manager as Capsule ;
1716use Illuminate \Database \Connection ;
1817use Illuminate \Database \DatabaseManager ;
@@ -33,12 +32,12 @@ class MigrateResetHardCommandTest extends TestCase
3332
3433 public function testResetWithNoTables (): void
3534 {
36- $ schema = Mockery::mock (AbstractSchemaManager ::class)
37- ->shouldReceive ('listTableNames ' )->once ()->andReturn ([])
35+ $ schema = Mockery::mock (Builder ::class)
36+ ->shouldReceive ('getTableListing ' )->once ()->andReturn ([])
3837 ->getMock ();
3938
4039 $ connection = Mockery::mock (Connection::class)
41- ->shouldReceive ('getDoctrineSchemaManager ' )->once ()->andReturn ($ schema )
40+ ->shouldReceive ('getSchemaBuilder ' )->once ()->andReturn ($ schema )
4241 ->getMock ();
4342
4443 $ db = Mockery::mock (Capsule::class)
@@ -58,14 +57,16 @@ public function testResetWithNoTables(): void
5857
5958 public function testReset (): void
6059 {
61- $ schema = Mockery::mock (AbstractSchemaManager::class)
62- ->shouldReceive ('listTableNames ' )->once ()->andReturn (['foo ' , 'bar ' ])
63- ->shouldReceive ('dropTable ' )->with ('foo ' )->once ()
64- ->shouldReceive ('dropTable ' )->with ('bar ' )->once ()
60+ $ schema = Mockery::mock (Builder::class)
61+ ->shouldReceive ('getTableListing ' )->once ()->andReturn (['foo ' , 'bar ' ])
62+ ->shouldReceive ('disableForeignKeyConstraints ' )->once ()
63+ ->shouldReceive ('enableForeignKeyConstraints ' )->once ()
64+ ->shouldReceive ('drop ' )->with ('foo ' )->once ()
65+ ->shouldReceive ('drop ' )->with ('bar ' )->once ()
6566 ->getMock ();
6667
6768 $ connection = Mockery::mock (Connection::class)
68- ->shouldReceive ('getDoctrineSchemaManager ' )->once ()->andReturn ($ schema )
69+ ->shouldReceive ('getSchemaBuilder ' )->once ()->andReturn ($ schema )
6970 ->shouldReceive ('getName ' )->once ()->andReturn ('foobar ' )
7071 ->getMock ();
7172
@@ -90,14 +91,16 @@ public function testReset(): void
9091
9192 public function testResetWithForce (): void
9293 {
93- $ schema = Mockery::mock (AbstractSchemaManager::class)
94- ->shouldReceive ('listTableNames ' )->once ()->andReturn (['foo ' , 'bar ' ])
95- ->shouldReceive ('dropTable ' )->with ('foo ' )->once ()
96- ->shouldReceive ('dropTable ' )->with ('bar ' )->once ()
94+ $ schema = Mockery::mock (Builder::class)
95+ ->shouldReceive ('getTableListing ' )->once ()->andReturn (['foo ' , 'bar ' ])
96+ ->shouldReceive ('disableForeignKeyConstraints ' )->once ()
97+ ->shouldReceive ('enableForeignKeyConstraints ' )->once ()
98+ ->shouldReceive ('drop ' )->with ('foo ' )->once ()
99+ ->shouldReceive ('drop ' )->with ('bar ' )->once ()
97100 ->getMock ();
98101
99102 $ connection = Mockery::mock (Connection::class)
100- ->shouldReceive ('getDoctrineSchemaManager ' )->once ()->andReturn ($ schema )
103+ ->shouldReceive ('getSchemaBuilder ' )->once ()->andReturn ($ schema )
101104 ->shouldNotReceive ('getName ' ) // NOT
102105 ->getMock ();
103106
@@ -122,12 +125,12 @@ public function testResetWithForce(): void
122125
123126 public function testResetWithDeniedConfirmation (): void
124127 {
125- $ schema = Mockery::mock (AbstractSchemaManager ::class)
126- ->shouldReceive ('listTableNames ' )->once ()->andReturn (['foo ' , 'bar ' ])
128+ $ schema = Mockery::mock (Builder ::class)
129+ ->shouldReceive ('getTableListing ' )->once ()->andReturn (['foo ' , 'bar ' ])
127130 ->getMock ();
128131
129132 $ connection = Mockery::mock (Connection::class)
130- ->shouldReceive ('getDoctrineSchemaManager ' )->once ()->andReturn ($ schema )
133+ ->shouldReceive ('getSchemaBuilder ' )->once ()->andReturn ($ schema )
131134 ->shouldReceive ('getName ' )->once ()->andReturn ('foobar ' )
132135 ->getMock ();
133136
@@ -151,14 +154,16 @@ public function testResetWithDeniedConfirmation(): void
151154
152155 public function testResetWithDatabase (): void
153156 {
154- $ schema = Mockery::mock (AbstractSchemaManager::class)
155- ->shouldReceive ('listTableNames ' )->once ()->andReturn (['foo ' , 'bar ' ])
156- ->shouldReceive ('dropTable ' )->with ('foo ' )->once ()
157- ->shouldReceive ('dropTable ' )->with ('bar ' )->once ()
157+ $ schema = Mockery::mock (Builder::class)
158+ ->shouldReceive ('getTableListing ' )->once ()->andReturn (['foo ' , 'bar ' ])
159+ ->shouldReceive ('disableForeignKeyConstraints ' )->once ()
160+ ->shouldReceive ('enableForeignKeyConstraints ' )->once ()
161+ ->shouldReceive ('drop ' )->with ('foo ' )->once ()
162+ ->shouldReceive ('drop ' )->with ('bar ' )->once ()
158163 ->getMock ();
159164
160165 $ connection = Mockery::mock (Connection::class)
161- ->shouldReceive ('getDoctrineSchemaManager ' )->once ()->andReturn ($ schema )
166+ ->shouldReceive ('getSchemaBuilder ' )->once ()->andReturn ($ schema )
162167 ->shouldReceive ('getName ' )->once ()->andReturn ('foobar ' )
163168 ->getMock ();
164169
@@ -192,14 +197,11 @@ public function testPretendReset(): void
192197 $ queries1 = [['query ' => 'drop table "forbar" ' ]];
193198 $ queries2 = [['query ' => 'drop table "barfoo" ' ]];
194199
195- $ doctrineSchema = Mockery::mock (AbstractSchemaManager ::class)
196- ->shouldReceive ('listTableNames ' )->once ()->andReturn (['foo/bar ' , 'bar/foo ' ])
200+ $ schema = Mockery::mock (Builder ::class)
201+ ->shouldReceive ('getTableListing ' )->once ()->andReturn (['foo/bar ' , 'bar/foo ' ])
197202 ->getMock ();
198203
199- $ schema = Mockery::mock (Builder::class);
200-
201204 $ connection = Mockery::mock (Connection::class)
202- ->shouldReceive ('getDoctrineSchemaManager ' )->once ()->andReturn ($ doctrineSchema )
203205 ->shouldReceive ('getSchemaBuilder ' )->once ()->andReturn ($ schema )
204206 ->shouldReceive ('pretend ' )->once ()->andReturn ($ queries1 )
205207 ->shouldReceive ('pretend ' )->once ()->andReturn ($ queries2 )
@@ -227,14 +229,11 @@ public function testPretendReset(): void
227229
228230 public function testPretendResetWithNoTables (): void
229231 {
230- $ doctrineSchema = Mockery::mock (AbstractSchemaManager ::class)
231- ->shouldReceive ('listTableNames ' )->once ()->andReturn ([])
232+ $ schema = Mockery::mock (Builder ::class)
233+ ->shouldReceive ('getTableListing ' )->once ()->andReturn ([])
232234 ->getMock ();
233235
234- $ schema = Mockery::mock (Builder::class);
235-
236236 $ connection = Mockery::mock (Connection::class)
237- ->shouldReceive ('getDoctrineSchemaManager ' )->once ()->andReturn ($ doctrineSchema )
238237 ->shouldReceive ('getSchemaBuilder ' )->once ()->andReturn ($ schema )
239238 ->getMock ();
240239
0 commit comments