@@ -400,34 +400,30 @@ public function testGenerateRelationshipColumnWithUlidModel()
400400
401401 public function testGenerateRelationshipConstrainedColumn ()
402402 {
403- $ base = new Blueprint ('posts ' , function ($ table ) {
404- $ table ->foreignIdFor ('Illuminate\Foundation\Auth\User ' )->constrained ();
405- });
406-
407- $ connection = m::mock (Connection::class);
408-
409- $ blueprint = clone $ base ;
403+ $ getSql = function ($ grammar ) {
404+ return $ this ->getBlueprint ($ grammar , 'posts ' , function ($ table ) {
405+ $ table ->foreignIdFor ('Illuminate\Foundation\Auth\User ' )->constrained ();
406+ })->toSql ();
407+ };
410408
411409 $ this ->assertEquals ([
412410 'alter table `posts` add `user_id` bigint unsigned not null ' ,
413411 'alter table `posts` add constraint `posts_user_id_foreign` foreign key (`user_id`) references `users` (`id`) ' ,
414- ], $ blueprint -> toSql ( $ connection , new MySqlGrammar ));
412+ ], $ getSql ( new MySqlGrammar ));
415413 }
416414
417415 public function testGenerateRelationshipForModelWithNonStandardPrimaryKeyName ()
418416 {
419- $ base = new Blueprint ('posts ' , function ($ table ) {
420- $ table ->foreignIdFor (User::class)->constrained ();
421- });
422-
423- $ connection = m::mock (Connection::class);
424-
425- $ blueprint = clone $ base ;
417+ $ getSql = function ($ grammar ) {
418+ return $ this ->getBlueprint ($ grammar , 'posts ' , function ($ table ) {
419+ $ table ->foreignIdFor (User::class)->constrained ();
420+ })->toSql ();
421+ };
426422
427423 $ this ->assertEquals ([
428424 'alter table `posts` add `user_internal_id` bigint unsigned not null ' ,
429425 'alter table `posts` add constraint `posts_user_internal_id_foreign` foreign key (`user_internal_id`) references `users` (`internal_id`) ' ,
430- ], $ blueprint -> toSql ( $ connection , new MySqlGrammar ));
426+ ], $ getSql ( new MySqlGrammar ));
431427 }
432428
433429 public function testDropRelationshipColumnWithIncrementalModel ()
0 commit comments