33namespace Tests \Commands ;
44
55use Exception ;
6+ use Illuminate \Support \Str ;
67use Tests \TestCase ;
8+ use Throwable ;
79
810class MigrateTest extends TestCase
911{
@@ -131,7 +133,6 @@ public function testSingleEnvironment()
131133 $ this ->assertDatabaseMigrationHas ($ this ->table , 'run_on_testing ' );
132134 $ this ->assertDatabaseMigrationHas ($ this ->table , 'run_except_production ' );
133135 $ this ->assertDatabaseMigrationDoesntLike ($ this ->table , 'run_except_testing ' );
134- $ this ->artisan ('migrate:actions ' )->run ();
135136 }
136137
137138 public function testManyEnvironments ()
@@ -173,7 +174,6 @@ public function testManyEnvironments()
173174 $ this ->assertDatabaseMigrationHas ($ this ->table , 'run_except_production ' );
174175 $ this ->assertDatabaseMigrationDoesntLike ($ this ->table , 'run_except_testing ' );
175176 $ this ->assertDatabaseMigrationDoesntLike ($ this ->table , 'run_except_many_environments ' );
176- $ this ->artisan ('migrate:actions ' )->run ();
177177 }
178178
179179 public function testAllow ()
@@ -200,7 +200,6 @@ public function testAllow()
200200 $ this ->assertDatabaseCount ($ this ->table , 7 );
201201 $ this ->assertDatabaseMigrationHas ($ this ->table , 'run_allow ' );
202202 $ this ->assertDatabaseMigrationDoesntLike ($ this ->table , 'run_disallow ' );
203- $ this ->artisan ('migrate:actions ' )->run ();
204203 }
205204
206205 public function testUpSuccess ()
@@ -219,24 +218,40 @@ public function testUpSuccess()
219218 $ this ->assertDatabaseCount ($ table , 2 );
220219 $ this ->assertDatabaseCount ($ this ->table , 7 );
221220 $ this ->assertDatabaseMigrationHas ($ this ->table , 'run_success ' );
222- $ this ->artisan ('migrate:actions ' )->run ();
223221 }
224222
225- public function testUpSuccessOnFailed ()
223+ public function testUpFailed ()
226224 {
227- $ this ->expectException (Exception::class);
228- $ this ->expectExceptionMessage ('Custom exception ' );
229-
230- $ this ->copyFiles (true );
225+ $ this ->copyFiles ();
231226
232227 $ table = 'success ' ;
233228
234229 $ this ->artisan ('migrate:actions:install ' )->run ();
235230
236231 $ this ->assertDatabaseCount ($ table , 0 );
237232 $ this ->assertDatabaseCount ($ this ->table , 0 );
238- $ this ->assertDatabaseMigrationDoesntLike ($ this ->table , 'run_success ' );
233+ $ this ->assertDatabaseMigrationDoesntLike ($ this ->table , 'run_success_on_failed ' );
239234 $ this ->artisan ('migrate:actions ' )->run ();
235+
236+ $ this ->assertDatabaseCount ($ table , 2 );
237+ $ this ->assertDatabaseCount ($ this ->table , 7 );
238+ $ this ->assertDatabaseMigrationDoesntLike ($ this ->table , 'run_success_on_failed ' );
239+
240+ try {
241+ $ this ->copyFiles (true );
242+
243+ $ this ->artisan ('migrate:actions ' )->run ();
244+ } catch (Throwable $ e ) {
245+ $ this ->assertInstanceOf (Exception::class, $ e );
246+
247+ $ this ->assertSame ('Custom exception ' , $ e ->getMessage ());
248+
249+ $ this ->assertTrue (Str::contains ($ e ->getFile (), 'run_success_on_failed ' ));
250+ }
251+
252+ $ this ->assertDatabaseCount ($ table , 2 );
253+ $ this ->assertDatabaseCount ($ this ->table , 7 );
254+ $ this ->assertDatabaseMigrationDoesntLike ($ this ->table , 'run_success_on_failed ' );
240255 }
241256
242257 public function testPathAsFileWithExtension ()
0 commit comments