@@ -780,6 +780,64 @@ public function output_works_with_polymorphic_relationships_laravel6()
780
780
$ this ->assertEquals (['created ' => [$ post_migration , $ user_migration , $ image_migration ]], $ this ->subject ->output ($ tree ));
781
781
}
782
782
783
+ /**
784
+ * @test
785
+ */
786
+ public function output_does_not_generate_relationship_for_uuid ()
787
+ {
788
+ $ this ->app ->config ->set ('blueprint.use_constraints ' , true );
789
+
790
+ $ this ->files ->expects ('stub ' )
791
+ ->with ('migration.stub ' )
792
+ ->andReturn ($ this ->stub ('migration.stub ' ));
793
+
794
+ $ now = Carbon::now ();
795
+ Carbon::setTestNow ($ now );
796
+
797
+ $ timestamp_path = 'database/migrations/ ' . $ now ->format ('Y_m_d_His ' ) . '_create_vats_table.php ' ;
798
+
799
+ $ this ->files ->expects ('exists ' )
800
+ ->with ($ timestamp_path )
801
+ ->andReturn (false );
802
+
803
+ $ this ->files ->expects ('put ' )
804
+ ->with ($ timestamp_path , $ this ->fixture ('migrations/uuid-without-relationship.php ' ));
805
+
806
+ $ tokens = $ this ->blueprint ->parse ($ this ->fixture ('drafts/uuid-without-relationship.yaml ' ));
807
+ $ tree = $ this ->blueprint ->analyze ($ tokens );
808
+
809
+ $ this ->assertEquals (['created ' => [$ timestamp_path ]], $ this ->subject ->output ($ tree ));
810
+ }
811
+
812
+ /**
813
+ * @test
814
+ */
815
+ public function output_generates_constraint_for_uuid ()
816
+ {
817
+ $ this ->app ->config ->set ('blueprint.use_constraints ' , true );
818
+
819
+ $ this ->files ->expects ('stub ' )
820
+ ->with ('migration.stub ' )
821
+ ->andReturn ($ this ->stub ('migration.stub ' ));
822
+
823
+ $ now = Carbon::now ();
824
+ Carbon::setTestNow ($ now );
825
+
826
+ $ timestamp_path = 'database/migrations/ ' . $ now ->format ('Y_m_d_His ' ) . '_create_people_table.php ' ;
827
+
828
+ $ this ->files ->expects ('exists ' )
829
+ ->with ($ timestamp_path )
830
+ ->andReturn (false );
831
+
832
+ $ this ->files ->expects ('put ' )
833
+ ->with ($ timestamp_path , $ this ->fixture ('migrations/uuid-shorthand-constraint.php ' ));
834
+
835
+ $ tokens = $ this ->blueprint ->parse ($ this ->fixture ('drafts/uuid-shorthand.yaml ' ));
836
+ $ tree = $ this ->blueprint ->analyze ($ tokens );
837
+
838
+ $ this ->assertEquals (['created ' => [$ timestamp_path ]], $ this ->subject ->output ($ tree ));
839
+ }
840
+
783
841
public function modelTreeDataProvider ()
784
842
{
785
843
return [
@@ -797,6 +855,7 @@ public function modelTreeDataProvider()
797
855
['drafts/disable-auto-columns.yaml ' , 'database/migrations/timestamp_create_states_table.php ' , 'migrations/disable-auto-columns.php ' ],
798
856
['drafts/uuid-shorthand.yaml ' , 'database/migrations/timestamp_create_people_table.php ' , 'migrations/uuid-shorthand.php ' ],
799
857
['drafts/uuid-shorthand-invalid-relationship.yaml ' , 'database/migrations/timestamp_create_age_cohorts_table.php ' , 'migrations/uuid-shorthand-invalid-relationship.php ' ],
858
+ ['drafts/uuid-without-relationship.yaml ' , 'database/migrations/timestamp_create_vats_table.php ' , 'migrations/uuid-without-relationship.php ' ],
800
859
['drafts/unconventional-foreign-key.yaml ' , 'database/migrations/timestamp_create_states_table.php ' , 'migrations/unconventional-foreign-key.php ' ],
801
860
['drafts/resource-statements.yaml ' , 'database/migrations/timestamp_create_users_table.php ' , 'migrations/resource-statements.php ' ],
802
861
['drafts/enum-options.yaml ' , 'database/migrations/timestamp_create_messages_table.php ' , 'migrations/enum-options.php ' ],
0 commit comments