@@ -190,4 +190,59 @@ public function testAddQueryPartWithAlias(): void
190190
191191 $ this ->assertEquals ('db_table_alias.DB_FIELD = :db_field_eq ' , (string )$ where );
192192 }
193+
194+ /** @dataProvider matchesDataProvider */
195+ public function testMatches (
196+ int $ stringForTrueCase ,
197+ mixed $ stringForFalseCase ,
198+ IntegerFilter $ initFilter
199+ ): void {
200+ $ this ->assertTrue ($ initFilter ->matches ($ stringForTrueCase ));
201+ $ this ->assertFalse ($ initFilter ->matches ($ stringForFalseCase ));
202+ }
203+
204+ public static function matchesDataProvider (): \Generator
205+ {
206+ yield "test match equals " => [
207+ 'stringForTrueCase ' => 1 ,
208+ 'stringForFalseCase ' => 2 ,
209+ 'initFilter ' => new IntegerFilter (equals: 1 )
210+ ];
211+
212+ yield "test match contains " => [
213+ 'stringForTrueCase ' => 1 ,
214+ 'stringForFalseCase ' => 5 ,
215+ 'initFilter ' => new IntegerFilter (lessThan: 3 )
216+ ];
217+
218+ yield "test match begins with " => [
219+ 'stringForTrueCase ' => 6 ,
220+ 'stringForFalseCase ' => 2 ,
221+ 'initFilter ' => new IntegerFilter (greaterThan: 4 )
222+ ];
223+
224+ yield "test match begins with and contains " => [
225+ 'stringForTrueCase ' => 5 ,
226+ 'stringForFalseCase ' => 2 ,
227+ 'initFilter ' => new IntegerFilter (between: [3 , 5 ])
228+ ];
229+
230+ yield "test match equals and contains " => [
231+ 'stringForTrueCase ' => 7 ,
232+ 'stringForFalseCase ' => 3 ,
233+ 'initFilter ' => new IntegerFilter (lessThan: 10 , greaterThan: 4 )
234+ ];
235+
236+ yield "test is and is not integer " => [
237+ 'stringForTrueCase ' => 2 ,
238+ 'stringForFalseCase ' => 2.1 ,
239+ 'initFilter ' => new IntegerFilter (equals: 2 )
240+ ];
241+
242+ yield "test is and is not integer with string " => [
243+ 'stringForTrueCase ' => 3 ,
244+ 'stringForFalseCase ' => '3 ' ,
245+ 'initFilter ' => new IntegerFilter (equals: 3 )
246+ ];
247+ }
193248}
0 commit comments