@@ -58,7 +58,7 @@ protected function seedDatabase(): void
58
58
'active ' => true ,
59
59
]);
60
60
61
- // set some translations
61
+ // Set some translations.
62
62
$ testModel ->translateOrNew ('nl ' )->translated_string = 'vertaalde_attribuutwaarde hoepla ' ;
63
63
$ testModel ->translateOrNew ('en ' )->translated_string = 'translated_attribute_value hoopla ' ;
64
64
$ testModel ->save ();
@@ -72,7 +72,7 @@ public function field_is_value_criteria_works(): void
72
72
{
73
73
$ this ->repository ->pushCriteria (new FieldIsValue ('name ' , 'special name ' ));
74
74
75
- $ this -> assertCount (1 , $ this ->repository ->all (), "FieldIsValue Criteria doesn't work " );
75
+ static :: assertCount (1 , $ this ->repository ->all (), "FieldIsValue Criteria doesn't work " );
76
76
}
77
77
78
78
/**
@@ -82,13 +82,19 @@ public function has_criteria_works(): void
82
82
{
83
83
$ this ->repository ->pushCriteria (new Has ('translations ' , '> ' , 1 ));
84
84
85
- $ this -> assertCount (1 , $ this ->repository ->all (), " Has Criteria simple use fails " );
85
+ static :: assertCount (1 , $ this ->repository ->all (), ' Has Criteria simple use fails ' );
86
86
87
- $ this ->repository ->pushCriteria (new Has ('translations ' , '= ' , 1 , 'and ' , function ($ query ) {
88
- return $ query ->where ('translated_string ' , 'vertaalde_attribuutwaarde hoepla ' );
89
- }));
87
+ $ this ->repository ->pushCriteria (
88
+ new Has (
89
+ 'translations ' ,
90
+ '= ' ,
91
+ 1 ,
92
+ 'and ' ,
93
+ fn ($ query ) => $ query ->where ('translated_string ' , 'vertaalde_attribuutwaarde hoepla ' )
94
+ )
95
+ );
90
96
91
- $ this -> assertCount (1 , $ this ->repository ->all (), " Has Criteria use with callback fails " );
97
+ static :: assertCount (1 , $ this ->repository ->all (), ' Has Criteria use with callback fails ' );
92
98
}
93
99
94
100
/**
@@ -98,7 +104,7 @@ public function is_active_criteria_works(): void
98
104
{
99
105
$ this ->repository ->pushCriteria (new IsActive ('active ' ));
100
106
101
- $ this -> assertCount (2 , $ this ->repository ->all (), "IsActive Criteria doesn't work " );
107
+ static :: assertCount (2 , $ this ->repository ->all (), "IsActive Criteria doesn't work " );
102
108
}
103
109
104
110
/**
@@ -108,7 +114,7 @@ public function order_by_criteria_works(): void
108
114
{
109
115
$ this ->repository ->pushCriteria (new OrderBy ('position ' , 'desc ' ));
110
116
111
- $ this -> assertEquals ([3 , 2 , 1 ], $ this ->repository ->pluck ('position ' )->all (), "OrderBy Criteria doesn't work " );
117
+ static :: assertEquals ([3 , 2 , 1 ], $ this ->repository ->pluck ('position ' )->all (), "OrderBy Criteria doesn't work " );
112
118
}
113
119
114
120
/**
@@ -118,11 +124,11 @@ public function scope_criteria_works(): void
118
124
{
119
125
$ this ->repository ->pushCriteria (new Scope ('testing ' ), CriteriaKey::SCOPE );
120
126
121
- $ this -> assertCount (2 , $ this ->repository ->all (), "Scope Criteria without parameters doesn't work " );
127
+ static :: assertCount (2 , $ this ->repository ->all (), "Scope Criteria without parameters doesn't work " );
122
128
123
- $ this ->repository ->pushCriteria (new Scope ('moreTesting ' , [ self ::SECOND_FIELD , '434 ' ]), CriteriaKey::SCOPE );
129
+ $ this ->repository ->pushCriteria (new Scope ('moreTesting ' , [self ::SECOND_FIELD , '434 ' ]), CriteriaKey::SCOPE );
124
130
125
- $ this -> assertCount (1 , $ this ->repository ->all (), "Scope Criteria with parameter doesn't work " );
131
+ static :: assertCount (1 , $ this ->repository ->all (), "Scope Criteria with parameter doesn't work " );
126
132
}
127
133
128
134
/**
@@ -132,48 +138,63 @@ public function scopes_criteria_works(): void
132
138
{
133
139
$ this ->repository ->pushCriteria (new Scopes ([
134
140
'testing ' ,
135
- 'moreTesting ' => [ 'active ' , false ],
141
+ 'moreTesting ' => ['active ' , false ],
136
142
]), CriteriaKey::SCOPE );
137
143
138
- $ this ->assertCount (1 , $ this ->repository ->all (), "Multiple Scopes Criteria doesn't work (value & key => value) " );
144
+ static ::assertCount (
145
+ 1 ,
146
+ $ this ->repository ->all (),
147
+ "Multiple Scopes Criteria doesn't work (value & key => value) "
148
+ );
139
149
140
150
$ this ->repository ->pushCriteria (new Scopes ([
141
- [ 'testing ' ],
142
- [ 'moreTesting ' , [ 'active ' , false ] ],
151
+ ['testing ' ],
152
+ ['moreTesting ' , ['active ' , false ] ],
143
153
]), CriteriaKey::SCOPE );
144
154
145
- $ this ->assertCount (1 , $ this ->repository ->all (), "Multiple Scopes Criteria doesn't work (array sets, no keys) " );
155
+ static ::assertCount (
156
+ 1 ,
157
+ $ this ->repository ->all (),
158
+ "Multiple Scopes Criteria doesn't work (array sets, no keys) "
159
+ );
146
160
}
147
161
148
162
/**
149
163
* @test
150
164
*/
151
165
public function where_has_criteria_works (): void
152
166
{
153
- $ this ->repository ->pushCriteria (new WhereHas ('translations ' , function ($ query ) {
154
- return $ query ->where ('translated_string ' , 'vertaalde_attribuutwaarde hoepla ' );
155
- }));
167
+ $ this ->repository ->pushCriteria (
168
+ new WhereHas (
169
+ 'translations ' ,
170
+ fn ($ query ) => $ query ->where ('translated_string ' , 'vertaalde_attribuutwaarde hoepla ' )
171
+ )
172
+ );
156
173
157
174
$ result = $ this ->repository ->all ();
158
- $ this ->assertCount (1 , $ result , "WhereHas Criteria doesn't work (wrong count) " );
159
- $ this ->assertEquals ('1337 ' , $ result ->first ()->{self ::UNIQUE_FIELD }, "WhereHas Criteria doesn't work (wrong model) " );
175
+ static ::assertCount (1 , $ result , "WhereHas Criteria doesn't work (wrong count) " );
176
+ static ::assertEquals (
177
+ '1337 ' ,
178
+ $ result ->first ()->{self ::UNIQUE_FIELD },
179
+ "WhereHas Criteria doesn't work (wrong model) "
180
+ );
160
181
}
161
182
162
183
/**
163
184
* @test
164
185
*/
165
- public function with_relations_criteria_works (): void
186
+ public function with_relations_criteria_works (): void
166
187
{
167
- $ this -> assertEmpty (
188
+ static :: assertEmpty (
168
189
$ this ->repository ->findBy (self ::UNIQUE_FIELD , '1337 ' )->getRelations (),
169
- " Model already includes translations relation without WithRelations Criteria "
190
+ ' Model already includes translations relation without WithRelations Criteria '
170
191
);
171
192
172
193
$ this ->repository ->pushCriteria (new WithRelations (['translations ' ]));
173
194
174
- $ this -> assertNotEmpty (
195
+ static :: assertNotEmpty (
175
196
$ this ->repository ->findBy (self ::UNIQUE_FIELD , '1337 ' )->getRelations (),
176
- " Model does not include translations relation with WithRelations Criteria "
197
+ ' Model does not include translations relation with WithRelations Criteria '
177
198
);
178
199
}
179
200
@@ -183,8 +204,6 @@ public function with_relations_criteria_works(): void
183
204
public function take_criteria_works (): void
184
205
{
185
206
$ this ->repository ->pushCriteria (new Take (2 ));
186
-
187
- $ this ->assertCount (2 , $ this ->repository ->all (), "Take Criteria doesn't work " );
207
+ static ::assertCount (2 , $ this ->repository ->all (), "Take Criteria doesn't work " );
188
208
}
189
-
190
209
}
0 commit comments