@@ -18,8 +18,8 @@ class MatchableFieldIntegrationTest extends IntegrationTestCase
1818{
1919 public function test_field_matchable_functionality_works (): void
2020 {
21- $ repository = new PostRepository () ;
22- $ request = new RestifyRequest () ;
21+ $ repository = new PostRepository ;
22+ $ request = new RestifyRequest ;
2323
2424 // Test that field matches are collected
2525 $ fieldMatches = PostRepository::collectFieldMatches ($ request , $ repository );
@@ -28,12 +28,12 @@ public function test_field_matchable_functionality_works(): void
2828 // Test field instances have matchable functionality
2929 $ fields = $ repository ->fields ($ request );
3030
31- $ titleField = collect ($ fields )->first (fn ($ field ) => $ field ->getAttribute () === 'title ' );
31+ $ titleField = collect ($ fields )->first (fn ($ field ) => $ field ->getAttribute () === 'title ' );
3232 $ this ->assertTrue ($ titleField ->isMatchable (), 'Title field should be matchable ' );
3333 $ this ->assertEquals ('title ' , $ titleField ->getMatchColumn ());
3434 $ this ->assertEquals ('text ' , $ titleField ->getMatchType ());
3535
36- $ isActiveField = collect ($ fields )->first (fn ($ field ) => $ field ->getAttribute () === 'is_active ' );
36+ $ isActiveField = collect ($ fields )->first (fn ($ field ) => $ field ->getAttribute () === 'is_active ' );
3737 $ this ->assertTrue ($ isActiveField ->isMatchable (), 'Is active field should be matchable ' );
3838 $ this ->assertEquals ('is_active ' , $ isActiveField ->getMatchColumn ());
3939 $ this ->assertEquals ('bool ' , $ isActiveField ->getMatchType ());
@@ -43,7 +43,7 @@ public function test_field_matchable_closure_works(): void
4343 {
4444 // Clear any existing posts to start fresh
4545 Post::query ()->delete ();
46-
46+
4747 // Register the test repository
4848 Restify::repositories ([
4949 TestMatchableRepository::class,
@@ -69,7 +69,7 @@ public function test_field_matchable_closure_works(): void
6969 $ this ->getJson (TestMatchableRepository::route ())
7070 ->assertStatus (200 )
7171 ->assertJson (
72- fn (AssertableJson $ json ) => $ json
72+ fn (AssertableJson $ json ) => $ json
7373 ->has ('data ' , 3 ) // Should have 3 posts total
7474 ->etc ()
7575 );
@@ -79,20 +79,20 @@ public function test_field_matchable_closure_works(): void
7979 $ this ->getJson (TestMatchableRepository::route (query: ['title ' => 'Framework ' ]))
8080 ->assertStatus (200 )
8181 ->assertJson (
82- fn (AssertableJson $ json ) => $ json
82+ fn (AssertableJson $ json ) => $ json
8383 ->has ('data ' , 2 ) // Should return exactly 2 posts matching "Framework"
8484 ->has ('data.0.attributes.title ' )
8585 ->has ('data.1.attributes.title ' )
86- ->where ('data.0.attributes.title ' , fn ($ title ) => in_array ($ title , [$ post1 ->title , $ post3 ->title ]))
87- ->where ('data.1.attributes.title ' , fn ($ title ) => in_array ($ title , [$ post1 ->title , $ post3 ->title ]))
86+ ->where ('data.0.attributes.title ' , fn ($ title ) => in_array ($ title , [$ post1 ->title , $ post3 ->title ]))
87+ ->where ('data.1.attributes.title ' , fn ($ title ) => in_array ($ title , [$ post1 ->title , $ post3 ->title ]))
8888 ->etc ()
8989 );
9090
91- // Test case insensitive search - search for 'laravel' should match post1
91+ // Test case insensitive search - search for 'laravel' should match post1
9292 $ this ->getJson (TestMatchableRepository::route (query: ['title ' => 'laravel ' ]))
9393 ->assertStatus (200 )
9494 ->assertJson (
95- fn (AssertableJson $ json ) => $ json
95+ fn (AssertableJson $ json ) => $ json
9696 ->has ('data ' , 1 ) // Should return exactly 1 post matching "laravel"
9797 ->where ('data.0.attributes.title ' , $ post1 ->title ) // Laravel Framework Guide
9898 ->etc ()
@@ -102,7 +102,7 @@ public function test_field_matchable_closure_works(): void
102102 $ this ->getJson (TestMatchableRepository::route (query: ['title ' => 'NonExistent ' ]))
103103 ->assertStatus (200 )
104104 ->assertJson (
105- fn (AssertableJson $ json ) => $ json
105+ fn (AssertableJson $ json ) => $ json
106106 ->has ('data ' , 0 ) // Should have 0 results for non-existent search
107107 ->etc ()
108108 );
@@ -112,7 +112,7 @@ public function test_field_matchable_with_custom_match_filter_works(): void
112112 {
113113 // Clear any existing posts to start fresh
114114 Post::query ()->delete ();
115-
115+
116116 // Register the test repository
117117 Restify::repositories ([
118118 TestMatchFilterRepository::class,
@@ -138,7 +138,7 @@ public function test_field_matchable_with_custom_match_filter_works(): void
138138 $ this ->getJson (TestMatchFilterRepository::route ())
139139 ->assertStatus (200 )
140140 ->assertJson (
141- fn (AssertableJson $ json ) => $ json
141+ fn (AssertableJson $ json ) => $ json
142142 ->has ('data ' , 3 ) // Should have 3 posts total
143143 ->etc ()
144144 );
@@ -149,7 +149,7 @@ public function test_field_matchable_with_custom_match_filter_works(): void
149149 $ this ->getJson (TestMatchFilterRepository::route (query: ['title ' => 'Laravel ' ]))
150150 ->assertStatus (200 )
151151 ->assertJson (
152- fn (AssertableJson $ json ) => $ json
152+ fn (AssertableJson $ json ) => $ json
153153 ->has ('data ' , 1 ) // Should return exactly 1 post starting with "Laravel"
154154 ->where ('data.0.attributes.title ' , $ post1 ->title ) // Laravel Framework Guide
155155 ->etc ()
@@ -160,7 +160,7 @@ public function test_field_matchable_with_custom_match_filter_works(): void
160160 $ this ->getJson (TestMatchFilterRepository::route (query: ['title ' => 'Framework ' ]))
161161 ->assertStatus (200 )
162162 ->assertJson (
163- fn (AssertableJson $ json ) => $ json
163+ fn (AssertableJson $ json ) => $ json
164164 ->has ('data ' , 1 ) // Should return exactly 1 post starting with "Framework"
165165 ->where ('data.0.attributes.title ' , $ post3 ->title ) // Framework Comparison
166166 ->etc ()
@@ -170,17 +170,17 @@ public function test_field_matchable_with_custom_match_filter_works(): void
170170 $ this ->getJson (TestMatchFilterRepository::route (query: ['title ' => 'Vue ' ]))
171171 ->assertStatus (200 )
172172 ->assertJson (
173- fn (AssertableJson $ json ) => $ json
173+ fn (AssertableJson $ json ) => $ json
174174 ->has ('data ' , 1 ) // Should return exactly 1 post starting with "Vue"
175175 ->where ('data.0.attributes.title ' , $ post2 ->title ) // Vue.js Tutorial
176176 ->etc ()
177177 );
178-
178+
179179 // Test no matches - search for something that doesn't exist
180180 $ this ->getJson (TestMatchFilterRepository::route (query: ['title ' => 'NonExistent ' ]))
181181 ->assertStatus (200 )
182182 ->assertJson (
183- fn (AssertableJson $ json ) => $ json
183+ fn (AssertableJson $ json ) => $ json
184184 ->has ('data ' , 0 ) // Should have 0 results for non-existent search
185185 ->etc ()
186186 );
@@ -250,7 +250,7 @@ public function filter(RestifyRequest $request, Builder|Relation $query, $value)
250250 {
251251 // Custom filtering logic: search for titles that start with the given value
252252 $ query ->where ('title ' , 'like ' , "{$ value }% " );
253-
253+
254254 return $ query ;
255255 }
256256}
@@ -262,7 +262,7 @@ class TestMatchFilterRepository extends Repository
262262 public function fields (RestifyRequest $ request ): array
263263 {
264264 return [
265- Field::make ('title ' )->matchable (new CustomTitleMatchFilter () ),
265+ Field::make ('title ' )->matchable (new CustomTitleMatchFilter ),
266266 Field::make ('description ' ),
267267 ];
268268 }
@@ -271,4 +271,4 @@ public static function uriKey(): string
271271 {
272272 return 'test-match-filter ' ;
273273 }
274- }
274+ }
0 commit comments