3
3
namespace Backpack \CRUD \Tests \Unit \CrudPanel ;
4
4
5
5
use Arr ;
6
- use Backpack \CRUD \Tests \ Unit \ Models \ User ;
6
+ use Backpack \CRUD \app \ Library \ CrudPanel \ CrudField ;
7
7
use Backpack \CRUD \Tests \Unit \Models \Star ;
8
+ use Backpack \CRUD \Tests \Unit \Models \User ;
8
9
use Illuminate \Http \Request ;
9
- use Backpack \CRUD \app \Library \CrudPanel \CrudField ;
10
10
11
11
/**
12
12
* @covers Backpack\CRUD\app\Library\CrudPanel\Traits\Fields
@@ -743,7 +743,9 @@ public function testItCanAddAFluentField()
743
743
->validationMessages (['required ' => 'is_required ' , 'min ' => 'min_2 ' ])
744
744
->store_in ('some ' )
745
745
->size (6 )
746
- ->on ('created ' , function () { return ; })
746
+ ->on ('created ' , function () {
747
+
748
+ })
747
749
->subfields ([['name ' => 'sub_1 ' ]])
748
750
->entity ('bang ' );
749
751
@@ -774,47 +776,48 @@ public function testItCanAddAFluentField()
774
776
'class ' => 'form-group col-md-6 ' ,
775
777
],
776
778
'events ' => [
777
- 'created ' => function () { return ; }
779
+ 'created ' => function () {
780
+
781
+ },
778
782
],
779
783
'subfields ' => [
780
784
[
781
785
'name ' => 'sub_1 ' ,
782
786
'parentFieldName ' => 'my_field ' ,
783
787
'type ' => 'text ' ,
784
788
'entity ' => false ,
785
- 'label ' => 'Sub 1 '
786
- ]
787
- ]
788
-
789
+ 'label ' => 'Sub 1 ' ,
790
+ ],
791
+ ],
789
792
790
793
], $ this ->crudPanel ->fields ()['my_field ' ]);
791
794
}
792
795
793
- public function testItCanMakeAFieldFirstFluently ()
796
+ public function testItCanMakeAFieldFirstFluently ()
794
797
{
795
798
$ this ->crudPanel ->field ('test1 ' );
796
799
$ this ->crudPanel ->field ('test2 ' )->makeFirst ();
797
800
$ crudFields = $ this ->crudPanel ->fields ();
798
801
$ firstField = reset ($ crudFields );
799
- $ this ->assertEquals ($ firstField ['name ' ],'test2 ' );
802
+ $ this ->assertEquals ($ firstField ['name ' ], 'test2 ' );
800
803
}
801
804
802
- public function testItCanMakeAFieldLastFluently ()
805
+ public function testItCanMakeAFieldLastFluently ()
803
806
{
804
807
$ this ->crudPanel ->field ('test1 ' );
805
808
$ this ->crudPanel ->field ('test2 ' );
806
809
$ this ->crudPanel ->field ('test1 ' )->makeLast ();
807
810
$ crudFields = $ this ->crudPanel ->fields ();
808
811
$ firstField = reset ($ crudFields );
809
- $ this ->assertEquals ($ firstField ['name ' ],'test2 ' );
812
+ $ this ->assertEquals ($ firstField ['name ' ], 'test2 ' );
810
813
}
811
814
812
- public function testItCanPlaceFieldsFluently ()
815
+ public function testItCanPlaceFieldsFluently ()
813
816
{
814
817
$ this ->crudPanel ->field ('test1 ' );
815
818
$ this ->crudPanel ->field ('test2 ' );
816
819
$ this ->crudPanel ->field ('test3 ' )->after ('test1 ' );
817
-
820
+
818
821
$ crudFieldsNames = array_column ($ this ->crudPanel ->fields (), 'name ' );
819
822
$ this ->assertEquals ($ crudFieldsNames , ['test1 ' , 'test3 ' , 'test2 ' ]);
820
823
@@ -823,61 +826,60 @@ public function testItCanPlaceFieldsFluently()
823
826
$ this ->assertEquals ($ crudFieldsNames , ['test4 ' , 'test1 ' , 'test3 ' , 'test2 ' ]);
824
827
}
825
828
826
- public function testItCanRemoveFieldAttributesFluently ()
829
+ public function testItCanRemoveFieldAttributesFluently ()
827
830
{
828
831
$ this ->crudPanel ->field ('test1 ' )->type ('test ' );
829
832
$ this ->assertEquals ($ this ->crudPanel ->fields ()['test1 ' ]['type ' ], 'test ' );
830
833
$ this ->crudPanel ->field ('test1 ' )->forget ('type ' );
831
834
$ this ->assertNull ($ this ->crudPanel ->fields ()['test1 ' ]['type ' ] ?? null );
832
835
}
833
836
834
- public function testItCanRemoveFieldFluently ()
837
+ public function testItCanRemoveFieldFluently ()
835
838
{
836
839
$ this ->crudPanel ->field ('test1 ' )->type ('test ' );
837
840
$ this ->assertCount (1 , $ this ->crudPanel ->fields ());
838
841
$ this ->crudPanel ->field ('test1 ' )->remove ();
839
842
$ this ->assertCount (0 , $ this ->crudPanel ->fields ());
840
843
}
841
844
842
- public function testItCanAddMorphFieldsFluently ()
845
+ public function testItCanAddMorphFieldsFluently ()
843
846
{
844
847
$ this ->crudPanel ->setModel (Star::class);
845
848
$ this ->crudPanel ->field ('starable ' )
846
849
->addMorphOption ('Backpack\CRUD\Tests\Unit\Models\User ' , 'User ' )
847
850
->morphTypeField (['attributes ' => ['custom-attribute ' => true ]])
848
851
->morphIdField (['attributes ' => ['custom-attribute ' => true ]]);
849
-
852
+
850
853
[$ morphTypeField , $ morphIdField ] = $ this ->crudPanel ->fields ()['starable ' ]['subfields ' ];
851
854
852
855
$ this ->assertTrue ($ morphTypeField ['attributes ' ]['custom-attribute ' ]);
853
856
$ this ->assertTrue ($ morphIdField ['attributes ' ]['custom-attribute ' ]);
854
857
}
855
858
856
- public function testAbortsConfiguringNonMorphTypeField ()
859
+ public function testAbortsConfiguringNonMorphTypeField ()
857
860
{
858
861
$ this ->crudPanel ->setModel (Star::class);
859
862
$ this ->expectException (\Exception::class);
860
863
$ this ->crudPanel ->field ('some_field ' )
861
864
->morphTypeField (['attributes ' => ['custom-attribute ' => true ]]);
862
865
}
863
866
864
- public function testAbortsConfiguringNonMorphIdField ()
867
+ public function testAbortsConfiguringNonMorphIdField ()
865
868
{
866
869
$ this ->crudPanel ->setModel (Star::class);
867
870
$ this ->expectException (\Exception::class);
868
871
$ this ->crudPanel ->field ('some_field ' )
869
872
->morphIdField (['attributes ' => ['custom-attribute ' => true ]]);
870
873
}
871
874
872
- public function testItCanGetTheFieldAttributes ()
875
+ public function testItCanGetTheFieldAttributes ()
873
876
{
874
-
875
877
$ this ->crudPanel ->field ('some_field ' );
876
878
877
879
$ this ->assertEquals ($ this ->crudPanel ->fields ()['some_field ' ], $ this ->crudPanel ->field ('some_field ' )->getAttributes ());
878
880
}
879
881
880
- public function testItAbortsWithEmptyNamesFluently ()
882
+ public function testItAbortsWithEmptyNamesFluently ()
881
883
{
882
884
try {
883
885
CrudField::name ('' );
0 commit comments