@@ -595,6 +595,38 @@ public function output_generates_models_with_custom_pivot(): void
595
595
$ this ->assertEquals (['created ' => ['app/Models/User.php ' , 'app/Models/Team.php ' , 'app/Models/Membership.php ' ]], $ this ->subject ->output ($ tree ));
596
596
}
597
597
598
+ #[Test]
599
+ public function output_generates_models_with_hasuuids_trait_if_uuid_id_is_type_uuid (): void
600
+ {
601
+ $ this ->filesystem ->expects ('stub ' )
602
+ ->with ('model.class.stub ' )
603
+ ->andReturn ($ this ->stub ('model.class.stub ' ));
604
+ $ this ->filesystem ->expects ('stub ' )
605
+ ->times (1 )
606
+ ->with ('model.casts.stub ' )
607
+ ->andReturn ($ this ->stub ('model.casts.stub ' ));
608
+ $ this ->filesystem ->expects ('stub ' )
609
+ ->times (1 )
610
+ ->with ('model.fillable.stub ' )
611
+ ->andReturn ($ this ->stub ('model.fillable.stub ' ));
612
+ $ this ->filesystem ->expects ('stub ' )
613
+ ->times (1 )
614
+ ->with ('model.method.stub ' )
615
+ ->andReturn ($ this ->stub ('model.method.stub ' ));
616
+
617
+ $ this ->filesystem ->expects ('exists ' )
618
+ ->times (1 )
619
+ ->with ('app/Models ' )
620
+ ->andReturnTrue ();
621
+
622
+ $ this ->filesystem ->expects ('put ' )
623
+ ->with ('app/Models/User.php ' , $ this ->fixture ('models/model-with-uuid-trait.php ' ));
624
+ $ tokens = $ this ->blueprint ->parse ($ this ->fixture ('drafts/model-with-uuid-id.yaml ' ));
625
+ $ tree = $ this ->blueprint ->analyze ($ tokens );
626
+
627
+ $ this ->assertEquals (['created ' => ['app/Models/User.php ' ]], $ this ->subject ->output ($ tree ));
628
+ }
629
+
598
630
public static function modelTreeDataProvider (): array
599
631
{
600
632
return [
@@ -610,6 +642,7 @@ public static function modelTreeDataProvider(): array
610
642
['drafts/uuid-shorthand-invalid-relationship.yaml ' , 'app/Models/AgeCohort.php ' , 'models/uuid-shorthand-invalid-relationship.php ' ],
611
643
['drafts/model-with-meta.yaml ' , 'app/Models/Post.php ' , 'models/model-with-meta.php ' ],
612
644
['drafts/infer-belongsto.yaml ' , 'app/Models/Conference.php ' , 'models/infer-belongsto.php ' ],
645
+ ['drafts/model-with-uuid-id.yaml ' , 'app/Models/User.php ' , 'models/model-with-uuid-trait.php ' ],
613
646
];
614
647
}
615
648
0 commit comments