@@ -349,6 +349,78 @@ public function testAttributeNotList()
349
349
$ this ->assertTrue ($ filter ->doesMatch (array ('id ' => 300 )));
350
350
}
351
351
352
+ public function testAttributeContainsString ()
353
+ {
354
+ $ filter = new QueryExpressionFilter (array (
355
+ 'key ' => array (
356
+ '$contains ' => 'value '
357
+ )
358
+ ));
359
+
360
+ $ this ->assertTrue ($ filter ->doesMatch (array (
361
+ 'key ' => 'the value exist '
362
+ )));
363
+ $ this ->assertFalse ($ filter ->doesMatch (array (
364
+ 'key ' => 'empty '
365
+ )));
366
+ }
367
+
368
+ public function testAttributeContainsArray ()
369
+ {
370
+ $ filter = new QueryExpressionFilter (array (
371
+ 'key ' => array (
372
+ '$contains ' => 'value '
373
+ )
374
+ ));
375
+
376
+ $ this ->assertTrue ($ filter ->doesMatch (array (
377
+ 'key ' => array ('the ' , 'value ' , 'exists ' )
378
+ )));
379
+ $ this ->assertFalse ($ filter ->doesMatch (array (
380
+ 'key ' => array ('not ' , 'present ' )
381
+ )));
382
+ }
383
+
384
+ public function testAttributeContainsAssoc ()
385
+ {
386
+ $ filter = new QueryExpressionFilter (array (
387
+ 'key ' => array (
388
+ '$contains ' => 'value '
389
+ )
390
+ ));
391
+
392
+ $ this ->assertTrue ($ filter ->doesMatch (array (
393
+ 'key ' => array (
394
+ 'value ' => 123
395
+ )
396
+ )));
397
+ $ this ->assertFalse ($ filter ->doesMatch (array (
398
+ 'key ' => array (
399
+ 'not ' => 'present '
400
+ )
401
+ )));
402
+ }
403
+
404
+ public function testAttributeContainsObject ()
405
+ {
406
+ $ filter = new QueryExpressionFilter (array (
407
+ 'key ' => array (
408
+ '$contains ' => 'value '
409
+ )
410
+ ));
411
+
412
+ $ this ->assertTrue ($ filter ->doesMatch ((object )array (
413
+ 'key ' => (object )array (
414
+ 'value ' => 123
415
+ )
416
+ )));
417
+ $ this ->assertFalse ($ filter ->doesMatch ((object )array (
418
+ 'key ' => (object )array (
419
+ 'not ' => 'present '
420
+ )
421
+ )));
422
+ }
423
+
352
424
/**
353
425
* @expectedException DomainException
354
426
*/
@@ -407,6 +479,24 @@ public function testInvalidOr()
407
479
$ filter ->doesMatch (array ('id ' => 100 ));
408
480
}
409
481
482
+ public function testAttributeContains ()
483
+ {
484
+ $ filter = new QueryExpressionFilter (array (
485
+ 'name ' => array (
486
+ '$contains ' => 'Fried '
487
+ )
488
+ ));
489
+
490
+ $ this ->assertFalse ($ filter ->doesMatch (array (
491
+ 'id ' => 100 ,
492
+ 'name ' => 'Smith, George '
493
+ )));
494
+ $ this ->assertTrue ($ filter ->doesMatch (array (
495
+ 'id ' => 300 ,
496
+ 'name ' => 'Smith, Friedrich '
497
+ )));
498
+ }
499
+
410
500
/**
411
501
* @dataProvider dpFetchValue
412
502
*/
0 commit comments