@@ -453,7 +453,7 @@ public function output_also_creates_pivot_table_migration_with_custom_name_larav
453
453
*/
454
454
public function output_creates_foreign_keys_with_nullable_chained_correctly ()
455
455
{
456
- $ this ->app ->config ->set ('blueprint.on_delete ' , 'set_null ' );
456
+ $ this ->app ->config ->set ('blueprint.on_delete ' , 'null ' );
457
457
458
458
$ this ->files ->expects ('stub ' )
459
459
->with ('migration.stub ' )
@@ -479,7 +479,7 @@ public function output_creates_foreign_keys_with_nullable_chained_correctly()
479
479
*/
480
480
public function output_creates_foreign_keys_with_nullable_chained_correctly_laravel6 ()
481
481
{
482
- $ this ->app ->config ->set ('blueprint.on_delete ' , 'set_null ' );
482
+ $ this ->app ->config ->set ('blueprint.on_delete ' , 'null ' );
483
483
484
484
$ app = \Mockery::mock ();
485
485
$ app ->shouldReceive ('version ' )
@@ -506,6 +506,60 @@ public function output_creates_foreign_keys_with_nullable_chained_correctly_lara
506
506
$ this ->assertEquals (['created ' => [$ model_migration ]], $ this ->subject ->output ($ tree ));
507
507
}
508
508
509
+ /**
510
+ * @test
511
+ */
512
+ public function output_creates_foreign_keys_with_on_delete ()
513
+ {
514
+ $ this ->files ->expects ('stub ' )
515
+ ->with ('migration.stub ' )
516
+ ->andReturn (file_get_contents ('stubs/migration.stub ' ));
517
+
518
+ $ now = Carbon::now ();
519
+ Carbon::setTestNow ($ now );
520
+
521
+ $ model_migration = str_replace ('timestamp ' , $ now ->format ('Y_m_d_His ' ), 'database/migrations/timestamp_create_comments_table.php ' );
522
+
523
+ $ this ->files
524
+ ->expects ('put ' )
525
+ ->with ($ model_migration , $ this ->fixture ('migrations/foreign-key-on-delete.php ' ));
526
+
527
+ $ tokens = $ this ->blueprint ->parse ($ this ->fixture ('definitions/foreign-key-on-delete.bp ' ));
528
+ $ tree = $ this ->blueprint ->analyze ($ tokens );
529
+
530
+ $ this ->assertEquals (['created ' => [$ model_migration ]], $ this ->subject ->output ($ tree ));
531
+ }
532
+
533
+ /**
534
+ * @test
535
+ */
536
+ public function output_creates_foreign_keys_with_on_delete_laravel6 ()
537
+ {
538
+ $ app = \Mockery::mock ();
539
+ $ app ->shouldReceive ('version ' )
540
+ ->withNoArgs ()
541
+ ->andReturn ('6.0.0 ' );
542
+ App::swap ($ app );
543
+
544
+ $ this ->files ->expects ('stub ' )
545
+ ->with ('migration.stub ' )
546
+ ->andReturn (file_get_contents ('stubs/migration.stub ' ));
547
+
548
+ $ now = Carbon::now ();
549
+ Carbon::setTestNow ($ now );
550
+
551
+ $ model_migration = str_replace ('timestamp ' , $ now ->format ('Y_m_d_His ' ), 'database/migrations/timestamp_create_comments_table.php ' );
552
+
553
+ $ this ->files
554
+ ->expects ('put ' )
555
+ ->with ($ model_migration , $ this ->fixture ('migrations/foreign-key-on-delete-laravel6.php ' ));
556
+
557
+ $ tokens = $ this ->blueprint ->parse ($ this ->fixture ('definitions/foreign-key-on-delete.bp ' ));
558
+ $ tree = $ this ->blueprint ->analyze ($ tokens );
559
+
560
+ $ this ->assertEquals (['created ' => [$ model_migration ]], $ this ->subject ->output ($ tree ));
561
+ }
562
+
509
563
/**
510
564
* @test
511
565
*/
0 commit comments