@@ -39,22 +39,22 @@ public function testOnce()
39
39
$ this ->artisan ('migrate:actions ' )->run ();
40
40
41
41
$ this ->assertDatabaseCount ($ table , 1 );
42
- $ this ->assertDatabaseCount ($ this ->table , 7 );
42
+ $ this ->assertDatabaseCount ($ this ->table , 8 );
43
43
$ this ->assertDatabaseMigrationDoesntLike ($ this ->table , $ table );
44
44
$ this ->artisan ('migrate:actions ' )->run ();
45
45
46
46
$ this ->assertDatabaseCount ($ table , 2 );
47
- $ this ->assertDatabaseCount ($ this ->table , 7 );
47
+ $ this ->assertDatabaseCount ($ this ->table , 8 );
48
48
$ this ->assertDatabaseMigrationDoesntLike ($ this ->table , $ table );
49
49
$ this ->artisan ('migrate:actions ' )->run ();
50
50
51
51
$ this ->assertDatabaseCount ($ table , 3 );
52
- $ this ->assertDatabaseCount ($ this ->table , 7 );
52
+ $ this ->assertDatabaseCount ($ this ->table , 8 );
53
53
$ this ->assertDatabaseMigrationDoesntLike ($ this ->table , $ table );
54
54
$ this ->artisan ('migrate:actions ' )->run ();
55
55
56
56
$ this ->assertDatabaseCount ($ table , 4 );
57
- $ this ->assertDatabaseCount ($ this ->table , 7 );
57
+ $ this ->assertDatabaseCount ($ this ->table , 8 );
58
58
$ this ->assertDatabaseMigrationDoesntLike ($ this ->table , $ table );
59
59
}
60
60
@@ -118,7 +118,7 @@ public function testSingleEnvironment()
118
118
$ this ->artisan ('migrate:actions ' )->run ();
119
119
120
120
$ this ->assertDatabaseCount ($ table , 5 );
121
- $ this ->assertDatabaseCount ($ this ->table , 7 );
121
+ $ this ->assertDatabaseCount ($ this ->table , 8 );
122
122
$ this ->assertDatabaseMigrationHas ($ this ->table , 'run_on_all ' );
123
123
$ this ->assertDatabaseMigrationDoesntLike ($ this ->table , 'run_on_production ' );
124
124
$ this ->assertDatabaseMigrationHas ($ this ->table , 'run_on_testing ' );
@@ -127,7 +127,7 @@ public function testSingleEnvironment()
127
127
$ this ->artisan ('migrate:actions ' )->run ();
128
128
129
129
$ this ->assertDatabaseCount ($ table , 5 );
130
- $ this ->assertDatabaseCount ($ this ->table , 7 );
130
+ $ this ->assertDatabaseCount ($ this ->table , 8 );
131
131
$ this ->assertDatabaseMigrationHas ($ this ->table , 'run_on_all ' );
132
132
$ this ->assertDatabaseMigrationDoesntLike ($ this ->table , 'run_on_production ' );
133
133
$ this ->assertDatabaseMigrationHas ($ this ->table , 'run_on_testing ' );
@@ -155,7 +155,7 @@ public function testManyEnvironments()
155
155
$ this ->artisan ('migrate:actions ' )->run ();
156
156
157
157
$ this ->assertDatabaseCount ($ table , 5 );
158
- $ this ->assertDatabaseCount ($ this ->table , 7 );
158
+ $ this ->assertDatabaseCount ($ this ->table , 8 );
159
159
$ this ->assertDatabaseMigrationHas ($ this ->table , 'run_on_all ' );
160
160
$ this ->assertDatabaseMigrationDoesntLike ($ this ->table , 'run_on_production ' );
161
161
$ this ->assertDatabaseMigrationHas ($ this ->table , 'run_on_testing ' );
@@ -166,7 +166,7 @@ public function testManyEnvironments()
166
166
$ this ->artisan ('migrate:actions ' )->run ();
167
167
168
168
$ this ->assertDatabaseCount ($ table , 5 );
169
- $ this ->assertDatabaseCount ($ this ->table , 7 );
169
+ $ this ->assertDatabaseCount ($ this ->table , 8 );
170
170
$ this ->assertDatabaseMigrationHas ($ this ->table , 'run_on_all ' );
171
171
$ this ->assertDatabaseMigrationDoesntLike ($ this ->table , 'run_on_production ' );
172
172
$ this ->assertDatabaseMigrationHas ($ this ->table , 'run_on_testing ' );
@@ -191,13 +191,13 @@ public function testAllow()
191
191
$ this ->artisan ('migrate:actions ' )->run ();
192
192
193
193
$ this ->assertDatabaseCount ($ table , 5 );
194
- $ this ->assertDatabaseCount ($ this ->table , 7 );
194
+ $ this ->assertDatabaseCount ($ this ->table , 8 );
195
195
$ this ->assertDatabaseMigrationHas ($ this ->table , 'run_allow ' );
196
196
$ this ->assertDatabaseMigrationDoesntLike ($ this ->table , 'run_disallow ' );
197
197
$ this ->artisan ('migrate:actions ' )->run ();
198
198
199
199
$ this ->assertDatabaseCount ($ table , 5 );
200
- $ this ->assertDatabaseCount ($ this ->table , 7 );
200
+ $ this ->assertDatabaseCount ($ this ->table , 8 );
201
201
$ this ->assertDatabaseMigrationHas ($ this ->table , 'run_allow ' );
202
202
$ this ->assertDatabaseMigrationDoesntLike ($ this ->table , 'run_disallow ' );
203
203
}
@@ -216,11 +216,11 @@ public function testUpSuccess()
216
216
$ this ->artisan ('migrate:actions ' )->run ();
217
217
218
218
$ this ->assertDatabaseCount ($ table , 2 );
219
- $ this ->assertDatabaseCount ($ this ->table , 7 );
219
+ $ this ->assertDatabaseCount ($ this ->table , 8 );
220
220
$ this ->assertDatabaseMigrationHas ($ this ->table , 'run_success ' );
221
221
}
222
222
223
- public function testUpFailed ()
223
+ public function testUpSuccessOnFailed ()
224
224
{
225
225
$ this ->copyFiles ();
226
226
@@ -234,11 +234,11 @@ public function testUpFailed()
234
234
$ this ->artisan ('migrate:actions ' )->run ();
235
235
236
236
$ this ->assertDatabaseCount ($ table , 2 );
237
- $ this ->assertDatabaseCount ($ this ->table , 7 );
237
+ $ this ->assertDatabaseCount ($ this ->table , 8 );
238
238
$ this ->assertDatabaseMigrationDoesntLike ($ this ->table , 'run_success_on_failed ' );
239
239
240
240
try {
241
- $ this ->copyFiles ( true );
241
+ $ this ->copySuccessFailureMethod ( );
242
242
243
243
$ this ->artisan ('migrate:actions ' )->run ();
244
244
} catch (Throwable $ e ) {
@@ -250,10 +250,62 @@ public function testUpFailed()
250
250
}
251
251
252
252
$ this ->assertDatabaseCount ($ table , 2 );
253
- $ this ->assertDatabaseCount ($ this ->table , 7 );
253
+ $ this ->assertDatabaseCount ($ this ->table , 8 );
254
254
$ this ->assertDatabaseMigrationDoesntLike ($ this ->table , 'run_success_on_failed ' );
255
255
}
256
256
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
+
257
309
public function testPathAsFileWithExtension ()
258
310
{
259
311
$ this ->copyFiles ();
0 commit comments