@@ -855,6 +855,7 @@ public function testHasManyCreatableRelationship()
855855 'remember_token ' => null ,
856856 'universes ' => [
857857 [
858+ 'id ' => null ,
858859 'title ' => 'this is the star 1 title ' ,
859860 ],
860861 [
@@ -872,17 +873,45 @@ public function testHasManyCreatableRelationship()
872873 $ inputData ['universes ' ] = [
873874 [
874875 'id ' => 1 ,
875- 'title ' => 'only one star with changed title ' ,
876+ 'title ' => 'star 1 with changed title ' ,
877+ ],
878+ [
879+ 'id ' => 2 ,
880+ 'title ' => 'star 2 with changed title ' ,
876881 ],
877882 ];
878883
879884 $ this ->crudPanel ->update ($ entry ->id , $ inputData );
880885
881- $ this ->assertCount (1 , $ entry ->fresh ()->universes );
886+ $ universes = $ entry ->fresh ()->universes ;
887+ $ this ->assertCount (2 , $ universes );
888+ $ this ->assertEquals ([1 , 2 ], $ universes ->pluck ('id ' )->toArray ());
889+
890+ $ inputData ['universes ' ] = [
891+ [
892+ 'id ' => 1 ,
893+ 'title ' => 'only one star with changed title ' ,
894+ ],
895+ ];
896+
897+ $ this ->crudPanel ->update ($ entry ->id , $ inputData );
882898
883899 $ this ->assertEquals ($ inputData ['universes ' ][0 ]['title ' ], $ entry ->fresh ()->universes ->first ()->title );
884900 $ this ->assertEquals ($ inputData ['universes ' ][0 ]['id ' ], $ entry ->fresh ()->universes ->first ()->id );
885901 $ this ->assertEquals (1 , Universe::all ()->count ());
902+
903+ $ inputData ['universes ' ] = [
904+ [
905+ 'id ' => null ,
906+ 'title ' => 'new star 3 ' ,
907+ ],
908+ ];
909+
910+ $ this ->crudPanel ->update ($ entry ->id , $ inputData );
911+
912+ $ this ->assertEquals ($ inputData ['universes ' ][0 ]['title ' ], $ entry ->fresh ()->universes ->first ()->title );
913+ $ this ->assertEquals (3 , $ entry ->fresh ()->universes ->first ()->id );
914+ $ this ->assertEquals (1 , Universe::all ()->count ());
886915 }
887916
888917 public function testHasManySelectableRelationshipWithoutForceDelete ()
0 commit comments