@@ -330,6 +330,103 @@ public function testStartsWithRegexQuestionmark()
330330 );
331331 }
332332
333+ public function testMatchesSingle ()
334+ {
335+ $ this ->provideTestObjects (10 );
336+ $ query = new ParseQuery ('TestObject ' );
337+ $ query ->matches ('foo ' , 'bar0 ' );
338+ $ results = $ query ->find ();
339+ $ this ->assertEquals (
340+ count ($ results ),
341+ 1 ,
342+ 'Matches function did not return correct number of objects. '
343+ );
344+ $ this ->assertEquals (
345+ $ results [0 ]->get ('foo ' ),
346+ 'bar0 ' ,
347+ 'Matches function did not return the correct object. '
348+ );
349+ }
350+
351+ public function testMatchesMultiple ()
352+ {
353+ $ this ->provideTestObjects (10 );
354+ $ query = new ParseQuery ('TestObject ' );
355+ $ query ->matches ('foo ' , 'bar ' );
356+ $ results = $ query ->find ();
357+ $ this ->assertEquals (
358+ count ($ results ),
359+ 10 ,
360+ 'Matches function did not return correct number of objects. '
361+ );
362+ }
363+
364+ public function testMatchesRegexDelimiters ()
365+ {
366+ $ testObject = ParseObject::create ('TestObject ' );
367+ $ testObject ->set ('foo ' , "foob\E " );
368+ $ testObject ->save ();
369+ $ query = new ParseQuery ('TestObject ' );
370+ $ query ->matches ('foo ' , 'foob\E ' );
371+ $ results = $ query ->find ();
372+ $ this ->assertEquals (
373+ count ($ results ),
374+ 1 ,
375+ 'Matches function did not return correct number of objects. '
376+ );
377+ $ query ->matches ('foo ' , 'foobE ' );
378+ $ results = $ query ->find ();
379+ $ this ->assertEquals (
380+ count ($ results ),
381+ 0 ,
382+ 'Matches function did not return correct number of objects. '
383+ );
384+ }
385+
386+ public function testMatchesCaseInsensitiveModifier ()
387+ {
388+ $ testObject = ParseObject::create ('TestObject ' );
389+ $ testObject ->set ('foo ' , 'FOOBAR ' );
390+ $ testObject ->save ();
391+ $ query = new ParseQuery ('TestObject ' );
392+ $ query ->matches ('foo ' , 'foo ' , 'i ' );
393+ $ results = $ query ->find ();
394+ $ this ->assertEquals (
395+ count ($ results ),
396+ 1 ,
397+ 'Matches function did not return correct number of objects. '
398+ );
399+ $ this ->assertEquals (
400+ $ results [0 ]->get ('foo ' ),
401+ 'FOOBAR ' ,
402+ 'Matches function did not return correct number of objects. '
403+ );
404+ }
405+
406+ public function testMatchesMultilineModifier ()
407+ {
408+ $ testObject = ParseObject::create ('TestObject ' );
409+ $ testObject ->set ('foo ' , 'foo\nbar ' );
410+ $ testObject ->save ();
411+ $ query = new ParseQuery ('TestObject ' );
412+ $ query ->matches ('foo ' , 'bar ' , 'm ' );
413+ $ results = $ query ->find ();
414+ $ this ->assertEquals (
415+ count ($ results ),
416+ 1 ,
417+ 'Matches function did not return correct number of objects. '
418+ );
419+ }
420+
421+ public function testMatchesBadOptions ()
422+ {
423+ $ this ->provideTestObjects (10 );
424+ $ query = new ParseQuery ('TestObject ' );
425+ $ query ->matches ('foo ' , 'bar ' , 'not-a-real-modifier ' );
426+ $ this ->setExpectedException ('Parse\ParseException ' , 'Bad $options value for query: not-a-real-modifier ' , 102 );
427+ $ query ->find ();
428+ }
429+
333430 public function testContainsSingle ()
334431 {
335432 $ testObject = ParseObject::create ('TestObject ' );
@@ -381,7 +478,7 @@ public function testContainsNonExistent()
381478 'Contains should not find. '
382479 );
383480 }
384-
481+
385482 public function testGreaterThan ()
386483 {
387484 $ this ->provideTestObjects (10 );
0 commit comments