@@ -546,6 +546,66 @@ public function testAddingForeignKey()
546546 $ this ->assertSame ('alter table `users` add constraint `users_foo_id_foreign` foreign key (`foo_id`) references `orders` (`id`) ' , $ statements [0 ]);
547547 }
548548
549+ public function testAddingForeignKeyWithCascadeOnDelete ()
550+ {
551+ $ blueprint = new Blueprint ('users ' );
552+ $ blueprint ->foreign ('foo_id ' )->references ('id ' )->on ('orders ' )->cascadeOnDelete ();
553+ $ statements = $ blueprint ->toSql ($ this ->getConnection (), $ this ->getGrammar ());
554+
555+ $ this ->assertCount (1 , $ statements );
556+ $ this ->assertSame ('alter table `users` add constraint `users_foo_id_foreign` foreign key (`foo_id`) references `orders` (`id`) on delete cascade ' , $ statements [0 ]);
557+ }
558+
559+ public function testAddingForeignKeyWithRestrictOnDelete ()
560+ {
561+ $ blueprint = new Blueprint ('users ' );
562+ $ blueprint ->foreign ('foo_id ' )->references ('id ' )->on ('orders ' )->restrictOnDelete ();
563+ $ statements = $ blueprint ->toSql ($ this ->getConnection (), $ this ->getGrammar ());
564+
565+ $ this ->assertCount (1 , $ statements );
566+ $ this ->assertSame ('alter table `users` add constraint `users_foo_id_foreign` foreign key (`foo_id`) references `orders` (`id`) on delete restrict ' , $ statements [0 ]);
567+ }
568+
569+ public function testAddingForeignKeyWithNoActionOnDelete ()
570+ {
571+ $ blueprint = new Blueprint ('users ' );
572+ $ blueprint ->foreign ('foo_id ' )->references ('id ' )->on ('orders ' )->noActionOnDelete ();
573+ $ statements = $ blueprint ->toSql ($ this ->getConnection (), $ this ->getGrammar ());
574+
575+ $ this ->assertCount (1 , $ statements );
576+ $ this ->assertSame ('alter table `users` add constraint `users_foo_id_foreign` foreign key (`foo_id`) references `orders` (`id`) on delete no action ' , $ statements [0 ]);
577+ }
578+
579+ public function testAddingForeignKeyWithRestrictOnUpdate ()
580+ {
581+ $ blueprint = new Blueprint ('users ' );
582+ $ blueprint ->foreign ('foo_id ' )->references ('id ' )->on ('orders ' )->restrictOnUpdate ();
583+ $ statements = $ blueprint ->toSql ($ this ->getConnection (), $ this ->getGrammar ());
584+
585+ $ this ->assertCount (1 , $ statements );
586+ $ this ->assertSame ('alter table `users` add constraint `users_foo_id_foreign` foreign key (`foo_id`) references `orders` (`id`) on update restrict ' , $ statements [0 ]);
587+ }
588+
589+ public function testAddingForeignKeyWithNullOnUpdate ()
590+ {
591+ $ blueprint = new Blueprint ('users ' );
592+ $ blueprint ->foreign ('foo_id ' )->references ('id ' )->on ('orders ' )->nullOnUpdate ();
593+ $ statements = $ blueprint ->toSql ($ this ->getConnection (), $ this ->getGrammar ());
594+
595+ $ this ->assertCount (1 , $ statements );
596+ $ this ->assertSame ('alter table `users` add constraint `users_foo_id_foreign` foreign key (`foo_id`) references `orders` (`id`) on update set null ' , $ statements [0 ]);
597+ }
598+
599+ public function testAddingForeignKeyWithNoActionOnUpdate ()
600+ {
601+ $ blueprint = new Blueprint ('users ' );
602+ $ blueprint ->foreign ('foo_id ' )->references ('id ' )->on ('orders ' )->noActionOnUpdate ();
603+ $ statements = $ blueprint ->toSql ($ this ->getConnection (), $ this ->getGrammar ());
604+
605+ $ this ->assertCount (1 , $ statements );
606+ $ this ->assertSame ('alter table `users` add constraint `users_foo_id_foreign` foreign key (`foo_id`) references `orders` (`id`) on update no action ' , $ statements [0 ]);
607+ }
608+
549609 public function testAddingIncrementingID ()
550610 {
551611 $ blueprint = new Blueprint ('users ' );
0 commit comments