Beispiel #1
0
 public function testOffset()
 {
     $offset = 123;
     $table = $this->getMockBuilder(\Sharkodlak\FluentDb\Table::class)->disableOriginalConstructor()->getMock();
     $factory = $this->getMockBuilder(\Sharkodlak\FluentDb\Factory\Factory::class)->getMock();
     $queryBuilder = $this->getMockBuilder(\Sharkodlak\FluentDb\Query\Builder::class)->setConstructorArgs(['SELECT', 'FROM'])->setMethods(['offset'])->getMock();
     $queryBuilder->expects($this->once())->method('offset')->with($this->equalTo($offset));
     $factory->expects($this->once())->method('getQueryBuilder')->will($this->returnValue($queryBuilder));
     $table->expects($this->once())->method('getFactory')->will($this->returnValue($factory));
     $query = new Select($table);
     $this->assertInstanceOf(Select::class, $query->offset($offset));
 }
Beispiel #2
0
 /**
  * Add limits so we retrieve only relavant rows
  *
  * @param Select $select Original select
  *
  * @return void
  */
 protected function setLimits($select)
 {
     if ($this->_show !== 0) {
         $select->limit($this->_show);
         $select->offset(($this->current_page - 1) * $this->_show);
     }
 }