@@ -390,6 +390,64 @@ public function output_does_not_duplicate_pivot_table_migration_laravel6()
390
390
$ this ->assertEquals (['created ' => [$ company_migration , $ people_migration , $ pivot_migration ]], $ this ->subject ->output ($ tree ));
391
391
}
392
392
393
+ /**
394
+ * @test
395
+ */
396
+ public function output_also_creates_pivot_table_migration_with_custom_name ()
397
+ {
398
+ $ this ->files ->expects ('stub ' )
399
+ ->with ('migration.stub ' )
400
+ ->andReturn (file_get_contents ('stubs/migration.stub ' ));
401
+
402
+ $ now = Carbon::now ();
403
+ Carbon::setTestNow ($ now );
404
+
405
+ $ model_migration = str_replace ('timestamp ' , $ now ->format ('Y_m_d_His ' ), 'database/migrations/timestamp_create_users_table.php ' );
406
+ $ pivot_migration = str_replace ('timestamp ' , $ now ->format ('Y_m_d_His ' ), 'database/migrations/timestamp_create_test_table.php ' );
407
+
408
+ $ this ->files ->expects ('put ' )
409
+ ->with ($ model_migration , $ this ->fixture ('migrations/custom-pivot-table-name-user.php ' ));
410
+ $ this ->files ->expects ('put ' )
411
+ ->with ($ pivot_migration , $ this ->fixture ('migrations/custom-pivot-table-name-test.php ' ));
412
+
413
+ $ tokens = $ this ->blueprint ->parse ($ this ->fixture ('definitions/custom-pivot-table-name.bp ' ));
414
+ $ tree = $ this ->blueprint ->analyze ($ tokens );
415
+
416
+ $ this ->assertEquals (['created ' => [$ model_migration , $ pivot_migration ]], $ this ->subject ->output ($ tree ));
417
+ }
418
+
419
+ /**
420
+ * @test
421
+ */
422
+ public function output_also_creates_pivot_table_migration_with_custom_name_laravel6 ()
423
+ {
424
+ $ app = \Mockery::mock ();
425
+ $ app ->shouldReceive ('version ' )
426
+ ->withNoArgs ()
427
+ ->andReturn ('6.0.0 ' );
428
+ App::swap ($ app );
429
+
430
+ $ this ->files ->expects ('stub ' )
431
+ ->with ('migration.stub ' )
432
+ ->andReturn (file_get_contents ('stubs/migration.stub ' ));
433
+
434
+ $ now = Carbon::now ();
435
+ Carbon::setTestNow ($ now );
436
+
437
+ $ model_migration = str_replace ('timestamp ' , $ now ->format ('Y_m_d_His ' ), 'database/migrations/timestamp_create_users_table.php ' );
438
+ $ pivot_migration = str_replace ('timestamp ' , $ now ->format ('Y_m_d_His ' ), 'database/migrations/timestamp_create_test_table.php ' );
439
+
440
+ $ this ->files ->expects ('put ' )
441
+ ->with ($ model_migration , $ this ->fixture ('migrations/custom-pivot-table-name-user-laravel6.php ' ));
442
+ $ this ->files ->expects ('put ' )
443
+ ->with ($ pivot_migration , $ this ->fixture ('migrations/custom-pivot-table-name-test-laravel6.php ' ));
444
+
445
+ $ tokens = $ this ->blueprint ->parse ($ this ->fixture ('definitions/custom-pivot-table-name.bp ' ));
446
+ $ tree = $ this ->blueprint ->analyze ($ tokens );
447
+
448
+ $ this ->assertEquals (['created ' => [$ model_migration , $ pivot_migration ]], $ this ->subject ->output ($ tree ));
449
+ }
450
+
393
451
/**
394
452
* @test
395
453
*/
0 commit comments