예제 #1
0
 public function testProcessLimitOffsetWithoutOptionalParams()
 {
     $offset = 1;
     $limit = 10;
     $select = new Select();
     $select->from('foo');
     $select->offset($offset);
     $select->limit($limit);
     $selectReflect = new \ReflectionObject($select);
     $method = $selectReflect->getMethod('processLimitOffset');
     $method->setAccessible(true);
     $return = $method->invokeArgs($select, [new TrustedSphinxQL()]);
     $this->assertEquals([$offset, $limit], $return);
     $method->setAccessible(false);
 }
예제 #2
0
 /**
  * @testdox Method reset() resets internal state of Select object, based on input
  * @covers SphinxSearch\Db\Sql\Select::reset
  */
 public function testReset()
 {
     $select = new Select();
     // table
     $select->from('foo');
     $this->assertEquals('foo', $select->getRawState(Select::TABLE));
     $select->reset(Select::TABLE);
     $this->assertNull($select->getRawState(Select::TABLE));
     // columns
     $select->columns(array('foo'));
     $this->assertEquals(array('foo'), $select->getRawState(Select::COLUMNS));
     $select->reset(Select::COLUMNS);
     $this->assertEmpty($select->getRawState(Select::COLUMNS));
     // where
     $select->where('foo = bar');
     $where1 = $select->getRawState(Select::WHERE);
     $this->assertEquals(1, $where1->count());
     $select->reset(Select::WHERE);
     $where2 = $select->getRawState(Select::WHERE);
     $this->assertEquals(0, $where2->count());
     $this->assertNotSame($where1, $where2);
     // group
     $select->group(array('foo'));
     $this->assertEquals(array('foo'), $select->getRawState(Select::GROUP));
     $select->reset(Select::GROUP);
     $this->assertEmpty($select->getRawState(Select::GROUP));
     // within group order by
     $select->withinGroupOrder(array('foo'));
     $this->assertEquals(array('foo'), $select->getRawState(Select::WITHINGROUPORDER));
     $select->reset(Select::WITHINGROUPORDER);
     $this->assertEmpty($select->getRawState(Select::WITHINGROUPORDER));
     // having
     $select->having('foo = bar');
     $having1 = $select->getRawState(Select::HAVING);
     $this->assertEquals(1, $having1->count());
     $select->reset(Select::HAVING);
     $having2 = $select->getRawState(Select::HAVING);
     $this->assertEquals(0, $having2->count());
     $this->assertNotSame($having1, $having2);
     // order
     $select->order('foo asc');
     $this->assertEquals(array('foo asc'), $select->getRawState(Select::ORDER));
     $select->reset(Select::ORDER);
     $this->assertEmpty($select->getRawState(Select::ORDER));
     // limit
     $select->limit(5);
     $this->assertEquals(5, $select->getRawState(Select::LIMIT));
     $select->reset(Select::LIMIT);
     $this->assertNull($select->getRawState(Select::LIMIT));
     // offset
     $select->offset(10);
     $this->assertEquals(10, $select->getRawState(Select::OFFSET));
     $select->reset(Select::OFFSET);
     $this->assertNull($select->getRawState(Select::OFFSET));
     // option
     $select->option(array('ranker' => 'bm25'));
     $this->assertEquals(array('ranker' => 'bm25'), $select->getRawState(Select::OPTION));
     $select->reset(Select::OPTION);
     $this->assertEmpty($select->getRawState(Select::OPTION));
 }