Ejemplo n.º 1
0
 /**
  * @covers Veles\DataBase\Adapters\PdoAdapter::getFoundRows
  */
 public function testGetFoundRows()
 {
     $expected = 100;
     $stmt = $this->getMockBuilder('\\PDOStatement')->setMethods(['fetchColumn'])->getMock();
     $stmt->expects($this->once())->method('fetchColumn')->willReturn($expected);
     $resource = $this->getMockBuilder('\\PDO')->disableOriginalConstructor()->setMethods(['prepare'])->getMock();
     $resource->expects($this->once())->method('prepare')->willReturn($stmt);
     $conn = $this->getMockBuilder('\\Veles\\DataBase\\Connections\\PdoConnection')->setConstructorArgs(['master'])->setMethods(['getResource'])->getMock();
     $conn->expects($this->once())->method('getResource')->willReturn($resource);
     $pool = $this->getMockBuilder('\\Veles\\DataBase\\ConnectionPools\\ConnectionPool')->setMethods(['getConnection'])->getMock();
     $pool->expects($this->once())->method('getConnection')->willReturn($conn);
     $this->object->setPool($pool);
     $actual = $this->object->getFoundRows();
     $msg = 'PdoAdapter::getFoundRows() returns wrong result!';
     $this->assertSame($expected, $actual, $msg);
 }