/**
  * @dataProvider provideEvaluations
  *
  * @param $string
  * @param $expected
  * @param Exception $expectedException
  */
 public function testEvaluations($string, $expected, Exception $expectedException = null)
 {
     if ($expectedException) {
         $this->setExpectedException(get_class($expectedException), $expectedException->getMessage());
     }
     $parser = new Parser();
     $compiler = new Compiler();
     $array = $compiler->compile($parser->parse($string));
     $this->assertEquals($expected, $array);
 }
 private function parseSearchQuery($searchQuery)
 {
     $parser = new Parser();
     // Handle a basic message search eg: 'foo bar'
     if ($parser->isSimpleLiteral($searchQuery)) {
         return array('message' => array('$regex' => $searchQuery));
     }
     // Handle a full query search eg: 'foo > bar'
     $compiler = new Compiler();
     try {
         return $compiler->compile($parser->parse($searchQuery));
     } catch (QueryParserException $e) {
         throw new InvalidSearchException(sprintf("Invalid search string '%s' near '%s'", $searchQuery, $e->getMessage()));
     } catch (LexingException $e) {
         throw new InvalidSearchException(sprintf("Invalid search string '%s' near '%s'", $searchQuery, $e->getMessage()));
     }
 }