@@ -39,22 +39,22 @@ public function testOnce()
3939 $ this ->artisan ('migrate:actions ' )->run ();
4040
4141 $ this ->assertDatabaseCount ($ table , 1 );
42- $ this ->assertDatabaseCount ($ this ->table , 7 );
42+ $ this ->assertDatabaseCount ($ this ->table , 8 );
4343 $ this ->assertDatabaseMigrationDoesntLike ($ this ->table , $ table );
4444 $ this ->artisan ('migrate:actions ' )->run ();
4545
4646 $ this ->assertDatabaseCount ($ table , 2 );
47- $ this ->assertDatabaseCount ($ this ->table , 7 );
47+ $ this ->assertDatabaseCount ($ this ->table , 8 );
4848 $ this ->assertDatabaseMigrationDoesntLike ($ this ->table , $ table );
4949 $ this ->artisan ('migrate:actions ' )->run ();
5050
5151 $ this ->assertDatabaseCount ($ table , 3 );
52- $ this ->assertDatabaseCount ($ this ->table , 7 );
52+ $ this ->assertDatabaseCount ($ this ->table , 8 );
5353 $ this ->assertDatabaseMigrationDoesntLike ($ this ->table , $ table );
5454 $ this ->artisan ('migrate:actions ' )->run ();
5555
5656 $ this ->assertDatabaseCount ($ table , 4 );
57- $ this ->assertDatabaseCount ($ this ->table , 7 );
57+ $ this ->assertDatabaseCount ($ this ->table , 8 );
5858 $ this ->assertDatabaseMigrationDoesntLike ($ this ->table , $ table );
5959 }
6060
@@ -118,7 +118,7 @@ public function testSingleEnvironment()
118118 $ this ->artisan ('migrate:actions ' )->run ();
119119
120120 $ this ->assertDatabaseCount ($ table , 5 );
121- $ this ->assertDatabaseCount ($ this ->table , 7 );
121+ $ this ->assertDatabaseCount ($ this ->table , 8 );
122122 $ this ->assertDatabaseMigrationHas ($ this ->table , 'run_on_all ' );
123123 $ this ->assertDatabaseMigrationDoesntLike ($ this ->table , 'run_on_production ' );
124124 $ this ->assertDatabaseMigrationHas ($ this ->table , 'run_on_testing ' );
@@ -127,7 +127,7 @@ public function testSingleEnvironment()
127127 $ this ->artisan ('migrate:actions ' )->run ();
128128
129129 $ this ->assertDatabaseCount ($ table , 5 );
130- $ this ->assertDatabaseCount ($ this ->table , 7 );
130+ $ this ->assertDatabaseCount ($ this ->table , 8 );
131131 $ this ->assertDatabaseMigrationHas ($ this ->table , 'run_on_all ' );
132132 $ this ->assertDatabaseMigrationDoesntLike ($ this ->table , 'run_on_production ' );
133133 $ this ->assertDatabaseMigrationHas ($ this ->table , 'run_on_testing ' );
@@ -155,7 +155,7 @@ public function testManyEnvironments()
155155 $ this ->artisan ('migrate:actions ' )->run ();
156156
157157 $ this ->assertDatabaseCount ($ table , 5 );
158- $ this ->assertDatabaseCount ($ this ->table , 7 );
158+ $ this ->assertDatabaseCount ($ this ->table , 8 );
159159 $ this ->assertDatabaseMigrationHas ($ this ->table , 'run_on_all ' );
160160 $ this ->assertDatabaseMigrationDoesntLike ($ this ->table , 'run_on_production ' );
161161 $ this ->assertDatabaseMigrationHas ($ this ->table , 'run_on_testing ' );
@@ -166,7 +166,7 @@ public function testManyEnvironments()
166166 $ this ->artisan ('migrate:actions ' )->run ();
167167
168168 $ this ->assertDatabaseCount ($ table , 5 );
169- $ this ->assertDatabaseCount ($ this ->table , 7 );
169+ $ this ->assertDatabaseCount ($ this ->table , 8 );
170170 $ this ->assertDatabaseMigrationHas ($ this ->table , 'run_on_all ' );
171171 $ this ->assertDatabaseMigrationDoesntLike ($ this ->table , 'run_on_production ' );
172172 $ this ->assertDatabaseMigrationHas ($ this ->table , 'run_on_testing ' );
@@ -191,13 +191,13 @@ public function testAllow()
191191 $ this ->artisan ('migrate:actions ' )->run ();
192192
193193 $ this ->assertDatabaseCount ($ table , 5 );
194- $ this ->assertDatabaseCount ($ this ->table , 7 );
194+ $ this ->assertDatabaseCount ($ this ->table , 8 );
195195 $ this ->assertDatabaseMigrationHas ($ this ->table , 'run_allow ' );
196196 $ this ->assertDatabaseMigrationDoesntLike ($ this ->table , 'run_disallow ' );
197197 $ this ->artisan ('migrate:actions ' )->run ();
198198
199199 $ this ->assertDatabaseCount ($ table , 5 );
200- $ this ->assertDatabaseCount ($ this ->table , 7 );
200+ $ this ->assertDatabaseCount ($ this ->table , 8 );
201201 $ this ->assertDatabaseMigrationHas ($ this ->table , 'run_allow ' );
202202 $ this ->assertDatabaseMigrationDoesntLike ($ this ->table , 'run_disallow ' );
203203 }
@@ -216,11 +216,11 @@ public function testUpSuccess()
216216 $ this ->artisan ('migrate:actions ' )->run ();
217217
218218 $ this ->assertDatabaseCount ($ table , 2 );
219- $ this ->assertDatabaseCount ($ this ->table , 7 );
219+ $ this ->assertDatabaseCount ($ this ->table , 8 );
220220 $ this ->assertDatabaseMigrationHas ($ this ->table , 'run_success ' );
221221 }
222222
223- public function testUpFailed ()
223+ public function testUpSuccessOnFailed ()
224224 {
225225 $ this ->copyFiles ();
226226
@@ -234,11 +234,11 @@ public function testUpFailed()
234234 $ this ->artisan ('migrate:actions ' )->run ();
235235
236236 $ this ->assertDatabaseCount ($ table , 2 );
237- $ this ->assertDatabaseCount ($ this ->table , 7 );
237+ $ this ->assertDatabaseCount ($ this ->table , 8 );
238238 $ this ->assertDatabaseMigrationDoesntLike ($ this ->table , 'run_success_on_failed ' );
239239
240240 try {
241- $ this ->copyFiles ( true );
241+ $ this ->copySuccessFailureMethod ( );
242242
243243 $ this ->artisan ('migrate:actions ' )->run ();
244244 } catch (Throwable $ e ) {
@@ -250,10 +250,62 @@ public function testUpFailed()
250250 }
251251
252252 $ this ->assertDatabaseCount ($ table , 2 );
253- $ this ->assertDatabaseCount ($ this ->table , 7 );
253+ $ this ->assertDatabaseCount ($ this ->table , 8 );
254254 $ this ->assertDatabaseMigrationDoesntLike ($ this ->table , 'run_success_on_failed ' );
255255 }
256256
257+ public function testUpFailed ()
258+ {
259+ $ this ->copyFiles ();
260+
261+ $ table = 'failed ' ;
262+
263+ $ this ->artisan ('migrate:actions:install ' )->run ();
264+
265+ $ this ->assertDatabaseCount ($ table , 0 );
266+ $ this ->assertDatabaseCount ($ this ->table , 0 );
267+ $ this ->assertDatabaseMigrationDoesntLike ($ this ->table , 'run_failed ' );
268+ $ this ->artisan ('migrate:actions ' )->run ();
269+
270+ $ this ->assertDatabaseCount ($ table , 0 );
271+ $ this ->assertDatabaseCount ($ this ->table , 8 );
272+ $ this ->assertDatabaseMigrationHas ($ this ->table , 'run_failed ' );
273+ }
274+
275+ public function testUpFailedOnException ()
276+ {
277+ $ this ->copyFiles ();
278+
279+ $ table = 'failed ' ;
280+
281+ $ this ->artisan ('migrate:actions:install ' )->run ();
282+
283+ $ this ->assertDatabaseCount ($ table , 0 );
284+ $ this ->assertDatabaseCount ($ this ->table , 0 );
285+ $ this ->assertDatabaseMigrationDoesntLike ($ this ->table , 'run_failed_failure ' );
286+ $ this ->artisan ('migrate:actions ' )->run ();
287+
288+ $ this ->assertDatabaseCount ($ table , 0 );
289+ $ this ->assertDatabaseCount ($ this ->table , 8 );
290+ $ this ->assertDatabaseMigrationDoesntLike ($ this ->table , 'run_failed_failure ' );
291+
292+ try {
293+ $ this ->copyFailedMethod ();
294+
295+ $ this ->artisan ('migrate:actions ' )->run ();
296+ } catch (Throwable $ e ) {
297+ $ this ->assertInstanceOf (Exception::class, $ e );
298+
299+ $ this ->assertSame ('Custom exception ' , $ e ->getMessage ());
300+
301+ $ this ->assertTrue (Str::contains ($ e ->getFile (), 'run_failed_failure ' ));
302+ }
303+
304+ $ this ->assertDatabaseCount ($ table , 1 );
305+ $ this ->assertDatabaseCount ($ this ->table , 8 );
306+ $ this ->assertDatabaseMigrationDoesntLike ($ this ->table , 'run_failed_failure ' );
307+ }
308+
257309 public function testPathAsFileWithExtension ()
258310 {
259311 $ this ->copyFiles ();
0 commit comments