/**
  * @covers Veles\DataBase\DbPaginator::__toString
  */
 public function test__toString()
 {
     $adapter = $this->getMockBuilder('\\Veles\\DataBase\\Adapters\\PdoAdapter')->setMethods(['rows', 'getFoundRows'])->getMock();
     $adapter->expects($this->once())->method('rows')->willReturn([1, 2, 3]);
     $adapter->expects($this->once())->method('getFoundRows')->willReturn(20);
     Db::setAdapter($adapter);
     $this->expectOutputString($this->html);
     $template = realpath(__DIR__ . '/../Project/View/paginator_default.phtml');
     $pager = new DbPaginator($template, 5);
     $news = new News();
     $pager->setLimit(1);
     $news->getAll(new DbFilter(), $pager);
     echo $pager;
 }
 /**
  * @covers       Veles\Model\ActiveRecord::query
  * @dataProvider queryProvider
  *
  * @param $pager
  * @param $expected
  * @param $found_rows
  */
 public function testQuery($pager, $expected, $found_rows)
 {
     $adapter = $this->getMockBuilder('\\Veles\\DataBase\\Adapters\\PdoAdapter')->setMethods(['rows', 'getFoundRows'])->getMock();
     $adapter->expects($this->once())->method('rows')->willReturn($expected);
     if ($found_rows) {
         $adapter->expects($this->once())->method('getFoundRows')->willReturn($found_rows);
     }
     Db::setAdapter($adapter);
     $sql = "SELECT * FROM user";
     $news = new News();
     $result = $news->query($sql, $pager);
     $msg = 'ActiveRecord::query() returns wrong result!';
     $this->assertSame($expected, $result, $msg);
 }