Пример #1
0
 public function testMerged()
 {
     $query = new Simples_Request_Search_Builder_Query();
     $query->match('scharrier')->in('username');
     $res = $query->to('array');
     $expected = array('term' => array('username' => 'scharrier'));
     $this->assertEquals($res, $expected);
     $query = new Simples_Request_Search_Builder_Query();
     $query->field('username')->match('scharrier');
     $res2 = $query->to('array');
     $this->assertEquals($res, $res2);
     $query = new Simples_Request_Search_Builder_Query();
     $query->fields(array('username', 'retweet'))->match('scharrier');
     $res = $query->to('array');
     $expected = array('query_string' => array('query' => 'scharrier', 'fields' => array('username', 'retweet')));
     $this->assertEquals($res, $expected);
     $query = new Simples_Request_Search_Builder_Query();
     $query->match('scharrier');
     $query->in(array('username', 'retweet'));
     $res = $query->to('array');
     $this->assertEquals($res, $expected);
     $query = new Simples_Request_Search_Builder_Query();
     $query->add(array('query' => 'scharrier', 'in' => array('username', 'retweet')));
     $res = $query->to('array');
     $this->assertEquals($res, $expected);
 }