99use Backpack \CRUD \Tests \Unit \Models \PlanetNonNullable ;
1010use Backpack \CRUD \Tests \Unit \Models \Universe ;
1111use Backpack \CRUD \Tests \Unit \Models \User ;
12+ use Backpack \CRUD \Tests \Unit \Models \Bill ;
1213use Faker \Factory ;
1314use Illuminate \Support \Arr ;
1415
1516/**
1617 * @covers Backpack\CRUD\app\Library\CrudPanel\Traits\Create
1718 * @covers Backpack\CRUD\app\Library\CrudPanel\Traits\Relationships
19+ * @covers Backpack\CRUD\app\Library\CrudPanel\Traits\FieldsProtectedMethods
20+ * @covers Backpack\CRUD\app\Library\CrudPanel\Traits\Update
1821 */
1922class CrudPanelCreateTest extends BaseDBCrudPanelTest
2023{
@@ -315,7 +318,6 @@ public function testGetRelationFieldsDotNotation()
315318
316319 //get all fields with a relation
317320 $ relationFields = $ this ->crudPanel ->getRelationFields ();
318- //var_dump($this->crudPanel->get('create.fields')['street']);
319321
320322 $ this ->assertEquals ($ this ->crudPanel ->get ('create.fields ' )['street ' ], Arr::last ($ relationFields ));
321323 }
@@ -340,6 +342,7 @@ public function testCreateHasOneRelations()
340342 ],
341343 ];
342344 $ entry = $ this ->crudPanel ->create ($ inputData );
345+ $ updateFields = $ this ->crudPanel ->getUpdateFields ($ entry ->id );
343346 $ account_details = $ entry ->accountDetails ()->first ();
344347
345348 $ this ->assertEquals ($ account_details ->nickname , 'i_have_has_one ' );
@@ -381,7 +384,7 @@ public function testGetRelationFieldsWithPivotNoRelations()
381384
382385 $ this ->assertEmpty ($ relationFields );
383386 }
384-
387+
385388 public function testMorphToManySelectableRelationship ()
386389 {
387390 $ this ->crudPanel ->setModel (User::class);
@@ -398,6 +401,8 @@ public function testMorphToManySelectableRelationship()
398401 ];
399402
400403 $ entry = $ this ->crudPanel ->create ($ inputData );
404+
405+ $ updateFields = $ this ->crudPanel ->getUpdateFields ($ entry ->id );
401406
402407 $ this ->assertCount (1 , $ entry ->bills );
403408
@@ -437,6 +442,7 @@ public function testMorphToManyCreatableRelationship()
437442 ];
438443
439444 $ entry = $ this ->crudPanel ->create ($ inputData );
445+ $ updateFields = $ this ->crudPanel ->getUpdateFields ($ entry ->id );
440446
441447 $ this ->assertCount (1 , $ entry ->recommends );
442448
@@ -494,7 +500,8 @@ public function testBelongsToManyWithPivotDataRelationship()
494500 ];
495501
496502 $ entry = $ this ->crudPanel ->create ($ inputData );
497-
503+ $ updateFields = $ this ->crudPanel ->getUpdateFields ($ entry ->id );
504+
498505 $ this ->assertCount (1 , $ entry ->fresh ()->superArticles );
499506 $ this ->assertEquals ('my first article note ' , $ entry ->fresh ()->superArticles ->first ()->pivot ->notes );
500507 }
@@ -580,6 +587,7 @@ public function testCreateHasOneWithNestedRelationsRepeatableInterface()
580587 ];
581588
582589 $ entry = $ this ->crudPanel ->create ($ inputData );
590+ $ updateFields = $ this ->crudPanel ->getUpdateFields ($ entry ->id );
583591 $ account_details = $ entry ->accountDetails ()->first ();
584592
585593 $ this ->assertEquals ($ account_details ->article , Article::find (1 ));
@@ -625,6 +633,7 @@ public function testCreateBelongsToFake()
625633 ];
626634
627635 $ entry = $ this ->crudPanel ->create ($ inputData );
636+ $ updateFields = $ this ->crudPanel ->getUpdateFields ($ entry ->id );
628637 $ this ->crudPanel ->entry = $ entry ->withFakes ();
629638 $ this ->assertEquals ($ entry ->bang_relation_field , 1 );
630639 }
@@ -705,6 +714,7 @@ public function testCreateHasOneWithNestedRelations()
705714 ];
706715
707716 $ entry = $ this ->crudPanel ->create ($ inputData );
717+ $ updateFields = $ this ->crudPanel ->getUpdateFields ($ entry ->id );
708718 $ account_details = $ entry ->accountDetails ()->first ();
709719
710720 $ this ->assertEquals ($ account_details ->article , Article::find (1 ));
@@ -773,6 +783,7 @@ public function testMorphOneRelationship()
773783 ];
774784
775785 $ entry = $ this ->crudPanel ->create ($ inputData );
786+ $ updateFields = $ this ->crudPanel ->getUpdateFields ($ entry ->id );
776787
777788 $ this ->assertEquals ($ inputData ['comment ' ]['text ' ], $ entry ->comment ->text );
778789
@@ -815,6 +826,7 @@ public function testMorphManyCreatableRelationship()
815826 ];
816827
817828 $ entry = $ this ->crudPanel ->create ($ inputData );
829+ $ updateFields = $ this ->crudPanel ->getUpdateFields ($ entry ->id );
818830
819831 $ this ->assertCount (2 , $ entry ->stars );
820832
@@ -866,6 +878,7 @@ public function testHasManyCreatableRelationship()
866878 ];
867879
868880 $ entry = $ this ->crudPanel ->create ($ inputData );
881+ $ updateFields = $ this ->crudPanel ->getUpdateFields ($ entry ->id );
869882
870883 $ this ->assertCount (2 , $ entry ->universes );
871884
@@ -942,6 +955,7 @@ public function testHasManySelectableRelationshipWithoutForceDelete()
942955 ];
943956
944957 $ entry = $ this ->crudPanel ->create ($ inputData );
958+ $ updateFields = $ this ->crudPanel ->getUpdateFields ($ entry ->id );
945959
946960 $ this ->assertCount (2 , $ entry ->planets );
947961
@@ -1384,5 +1398,7 @@ public function testBelongsToManyWithArrayedNameSubfields()
13841398 $ superArticle = $ entry ->fresh ()->superArticles ->first ();
13851399 $ this ->assertEquals ($ superArticle ->pivot ->start_date , '2021-02-26 ' );
13861400 $ this ->assertEquals ($ superArticle ->pivot ->end_date , '2091-01-26 ' );
1401+
1402+ $ this ->crudPanel ->getUpdateFields ($ superArticle ->id );
13871403 }
13881404}
0 commit comments