@@ -162,6 +162,37 @@ public function output_uses_past_timestamp_for_multiple_migrations()
162
162
$ this ->assertEquals (['created ' => [$ post_path , $ comment_path ]], $ this ->subject ->output ($ tree ));
163
163
}
164
164
165
+ /**
166
+ * @test
167
+ */
168
+ public function output_proper_pascal_case_model_names ()
169
+ {
170
+ $ this ->files ->expects ('stub ' )
171
+ ->with ('migration.stub ' )
172
+ ->andReturn ($ this ->stub ('migration.stub ' ));
173
+
174
+ $ now = Carbon::now ();
175
+ Carbon::setTestNow ($ now );
176
+
177
+ $ broker_path = str_replace ('timestamp ' , $ now ->copy ()->subSeconds (2 )->format ('Y_m_d_His ' ), 'database/migrations/timestamp_create_brokers_table.php ' );
178
+ $ broker_type_path = str_replace ('timestamp ' , $ now ->copy ()->subSecond ()->format ('Y_m_d_His ' ), 'database/migrations/timestamp_create_broker_types_table.php ' );
179
+ $ broker_broker_type_path = str_replace ('timestamp ' , $ now ->format ('Y_m_d_His ' ), 'database/migrations/timestamp_create_broker_broker_type_table.php ' );
180
+
181
+ $ this ->files ->expects ('exists ' )->times (3 )->andReturn (false );
182
+
183
+ $ this ->files ->expects ('put ' )
184
+ ->with ($ broker_path , $ this ->fixture ('migrations/pascal-case-model-names-broker.php ' ));
185
+ $ this ->files ->expects ('put ' )
186
+ ->with ($ broker_type_path , $ this ->fixture ('migrations/pascal-case-model-names-broker-type.php ' ));
187
+ $ this ->files ->expects ('put ' )
188
+ ->with ($ broker_broker_type_path , $ this ->fixture ('migrations/pascal-case-model-names-broker-broker-type.php ' ));
189
+
190
+ $ tokens = $ this ->blueprint ->parse ($ this ->fixture ('drafts/pascal-case-model-names.yaml ' ));
191
+ $ tree = $ this ->blueprint ->analyze ($ tokens );
192
+
193
+ $ this ->assertEquals (['created ' => [$ broker_path , $ broker_type_path , $ broker_broker_type_path ]], $ this ->subject ->output ($ tree ));
194
+ }
195
+
165
196
/**
166
197
* @test
167
198
* @environment-setup useLaravel6
@@ -255,7 +286,7 @@ public function output_also_creates_pivot_table_migration()
255
286
$ now = Carbon::now ();
256
287
Carbon::setTestNow ($ now );
257
288
258
- $ model_migration = str_replace ('timestamp ' , $ now ->format ('Y_m_d_His ' ), 'database/migrations/timestamp_create_journeys_table.php ' );
289
+ $ model_migration = str_replace ('timestamp ' , $ now ->copy ()-> subSecond ()-> format ('Y_m_d_His ' ), 'database/migrations/timestamp_create_journeys_table.php ' );
259
290
$ pivot_migration = str_replace ('timestamp ' , $ now ->format ('Y_m_d_His ' ), 'database/migrations/timestamp_create_diary_journey_table.php ' );
260
291
261
292
$ this ->files ->expects ('exists ' )->twice ()->andReturn (false );
@@ -320,7 +351,7 @@ public function output_also_creates_pivot_table_migration_laravel6()
320
351
$ now = Carbon::now ();
321
352
Carbon::setTestNow ($ now );
322
353
323
- $ model_migration = str_replace ('timestamp ' , $ now ->format ('Y_m_d_His ' ), 'database/migrations/timestamp_create_journeys_table.php ' );
354
+ $ model_migration = str_replace ('timestamp ' , $ now ->copy ()-> subSecond ()-> format ('Y_m_d_His ' ), 'database/migrations/timestamp_create_journeys_table.php ' );
324
355
$ pivot_migration = str_replace ('timestamp ' , $ now ->format ('Y_m_d_His ' ), 'database/migrations/timestamp_create_diary_journey_table.php ' );
325
356
326
357
$ this ->files ->expects ('exists ' )->twice ()->andReturn (false );
@@ -351,7 +382,7 @@ public function output_also_creates_constraints_for_pivot_table_migration()
351
382
$ now = Carbon::now ();
352
383
Carbon::setTestNow ($ now );
353
384
354
- $ model_migration = str_replace ('timestamp ' , $ now ->format ('Y_m_d_His ' ), 'database/migrations/timestamp_create_journeys_table.php ' );
385
+ $ model_migration = str_replace ('timestamp ' , $ now ->copy ()-> subSecond ()-> format ('Y_m_d_His ' ), 'database/migrations/timestamp_create_journeys_table.php ' );
355
386
$ pivot_migration = str_replace ('timestamp ' , $ now ->format ('Y_m_d_His ' ), 'database/migrations/timestamp_create_diary_journey_table.php ' );
356
387
357
388
$ this ->files ->expects ('exists ' )->twice ()->andReturn (false );
@@ -383,7 +414,7 @@ public function output_also_creates_constraints_for_pivot_table_migration_larave
383
414
$ now = Carbon::now ();
384
415
Carbon::setTestNow ($ now );
385
416
386
- $ model_migration = str_replace ('timestamp ' , $ now ->format ('Y_m_d_His ' ), 'database/migrations/timestamp_create_journeys_table.php ' );
417
+ $ model_migration = str_replace ('timestamp ' , $ now ->copy ()-> subSecond ()-> format ('Y_m_d_His ' ), 'database/migrations/timestamp_create_journeys_table.php ' );
387
418
$ pivot_migration = str_replace ('timestamp ' , $ now ->format ('Y_m_d_His ' ), 'database/migrations/timestamp_create_diary_journey_table.php ' );
388
419
389
420
$ this ->files ->expects ('exists ' )->twice ()->andReturn (false );
@@ -411,8 +442,8 @@ public function output_does_not_duplicate_pivot_table_migration()
411
442
$ now = Carbon::now ();
412
443
Carbon::setTestNow ($ now );
413
444
414
- $ company_migration = str_replace ('timestamp ' , $ now ->copy ()->subSecond ( )->format ('Y_m_d_His ' ), 'database/migrations/timestamp_create_companies_table.php ' );
415
- $ people_migration = str_replace ('timestamp ' , $ now ->format ('Y_m_d_His ' ), 'database/migrations/timestamp_create_people_table.php ' );
445
+ $ company_migration = str_replace ('timestamp ' , $ now ->copy ()->subSeconds ( 2 )->format ('Y_m_d_His ' ), 'database/migrations/timestamp_create_companies_table.php ' );
446
+ $ people_migration = str_replace ('timestamp ' , $ now ->copy ()-> subSecond ()-> format ('Y_m_d_His ' ), 'database/migrations/timestamp_create_people_table.php ' );
416
447
$ pivot_migration = str_replace ('timestamp ' , $ now ->format ('Y_m_d_His ' ), 'database/migrations/timestamp_create_company_person_table.php ' );
417
448
418
449
$ this ->files ->expects ('exists ' )->times (3 )->andReturn (false );
@@ -443,8 +474,8 @@ public function output_does_not_duplicate_pivot_table_migration_laravel6()
443
474
$ now = Carbon::now ();
444
475
Carbon::setTestNow ($ now );
445
476
446
- $ company_migration = str_replace ('timestamp ' , $ now ->copy ()->subSecond ( )->format ('Y_m_d_His ' ), 'database/migrations/timestamp_create_companies_table.php ' );
447
- $ people_migration = str_replace ('timestamp ' , $ now ->format ('Y_m_d_His ' ), 'database/migrations/timestamp_create_people_table.php ' );
477
+ $ company_migration = str_replace ('timestamp ' , $ now ->copy ()->subSeconds ( 2 )->format ('Y_m_d_His ' ), 'database/migrations/timestamp_create_companies_table.php ' );
478
+ $ people_migration = str_replace ('timestamp ' , $ now ->copy ()-> subSecond ()-> format ('Y_m_d_His ' ), 'database/migrations/timestamp_create_people_table.php ' );
448
479
$ pivot_migration = str_replace ('timestamp ' , $ now ->format ('Y_m_d_His ' ), 'database/migrations/timestamp_create_company_person_table.php ' );
449
480
450
481
$ this ->files ->expects ('exists ' )->times (3 )->andReturn (false );
@@ -474,7 +505,7 @@ public function output_also_creates_pivot_table_migration_with_custom_name()
474
505
$ now = Carbon::now ();
475
506
Carbon::setTestNow ($ now );
476
507
477
- $ model_migration = str_replace ('timestamp ' , $ now ->format ('Y_m_d_His ' ), 'database/migrations/timestamp_create_users_table.php ' );
508
+ $ model_migration = str_replace ('timestamp ' , $ now ->copy ()-> subSecond ()-> format ('Y_m_d_His ' ), 'database/migrations/timestamp_create_users_table.php ' );
478
509
$ pivot_migration = str_replace ('timestamp ' , $ now ->format ('Y_m_d_His ' ), 'database/migrations/timestamp_create_test_table.php ' );
479
510
480
511
$ this ->files ->expects ('exists ' )->twice ()->andReturn (false );
@@ -503,7 +534,7 @@ public function output_also_creates_pivot_table_migration_with_custom_name_larav
503
534
$ now = Carbon::now ();
504
535
Carbon::setTestNow ($ now );
505
536
506
- $ model_migration = str_replace ('timestamp ' , $ now ->format ('Y_m_d_His ' ), 'database/migrations/timestamp_create_users_table.php ' );
537
+ $ model_migration = str_replace ('timestamp ' , $ now ->copy ()-> subSecond ()-> format ('Y_m_d_His ' ), 'database/migrations/timestamp_create_users_table.php ' );
507
538
$ pivot_migration = str_replace ('timestamp ' , $ now ->format ('Y_m_d_His ' ), 'database/migrations/timestamp_create_test_table.php ' );
508
539
509
540
$ this ->files ->expects ('exists ' )->twice ()->andReturn (false );
0 commit comments