/**
  * @covers \Foolz\SphinxQL\SphinxQL::match
  * @covers \Foolz\SphinxQL\SphinxQL::compileMatch
  * @covers \Foolz\SphinxQL\SphinxQL::halfEscapeMatch
  */
 public function testMatch()
 {
     $this->refill();
     $result = SphinxQL::create(self::$conn)->select()->from('rt')->match('content', 'content')->execute()->getStored();
     $this->assertCount(2, $result);
     $result = SphinxQL::create(self::$conn)->select()->from('rt')->match('title', 'value')->execute()->getStored();
     $this->assertCount(1, $result);
     $result = SphinxQL::create(self::$conn)->select()->from('rt')->match('title', 'value')->match('content', 'directly')->execute()->getStored();
     $this->assertCount(1, $result);
     $result = SphinxQL::create(self::$conn)->select()->from('rt')->match('*', 'directly')->execute()->getStored();
     $this->assertCount(1, $result);
     $result = SphinxQL::create(self::$conn)->select()->from('rt')->match(array('title', 'content'), 'to')->execute()->getStored();
     $this->assertCount(3, $result);
     $result = SphinxQL::create(self::$conn)->select()->from('rt')->match('content', 'directly | lazy', true)->execute()->getStored();
     $this->assertCount(2, $result);
     $result = SphinxQL::create(self::$conn)->select()->from('rt')->match(function ($m) {
         $m->field('content')->match('directly')->orMatch('lazy');
     })->execute()->getStored();
     $this->assertCount(2, $result);
     $match = Match::create(SphinxQL::create(self::$conn))->field('content')->match('directly')->orMatch('lazy');
     $result = SphinxQL::create(self::$conn)->select()->from('rt')->match($match)->execute()->getStored();
     $this->assertCount(2, $result);
 }
 public function testCompile()
 {
     $match = Match::create(self::$sphinxql)->phrase('hello world')->field('title')->proximity('example program', 5)->field('body')->match('python')->not(function ($m) {
         $m->match('php')->orMatch('perl');
     })->field('*')->match('code');
     $this->assertEquals('"hello world" @title "example program"~5 @body python -(php | perl) @* code', $match->compile()->getCompiled());
     $match = Match::create(self::$sphinxql)->match('bag of words')->before()->phrase('exact phrase')->before('red')->orMatch('green')->orMatch('blue');
     $this->assertEquals('(bag of words) << "exact phrase" << red | green | blue', $match->compile()->getCompiled());
     $match = Match::create(self::$sphinxql)->match('aaa')->not(function ($m) {
         $m->match('bbb')->not('ccc ddd');
     });
     $this->assertEquals('aaa -(bbb -(ccc ddd))', $match->compile()->getCompiled());
 }