示例#1
0
 public function testDataIsLoadedOnlyOnce()
 {
     $fixtureSql = "SELECT * FROM foo";
     $statementMock = new Test\DbStatement();
     $statementMock->append(array('foo' => 'bar'));
     $adapterMock = $this->getMock('Zend\\Test\\DbAdapter');
     $adapterMock->expects($this->once())->method('query')->with($fixtureSql)->will($this->returnValue($statementMock));
     $this->decorateConnectionGetConnectionWith($adapterMock);
     $queryTable = new DataSet\QueryTable("foo", $fixtureSql, $this->connectionMock);
     $this->assertEquals(1, $queryTable->getRowCount());
     $this->assertEquals(1, $queryTable->getRowCount());
     $row = $queryTable->getRow(0);
     $this->assertEquals(array('foo' => 'bar'), $row);
 }
示例#2
0
 public function testAppendStatementToStack()
 {
     $stmt1 = Test\DbStatement::createSelectStatement(array());
     $this->_adapter->appendStatementToStack($stmt1);
     $stmt2 = Test\DbStatement::createSelectStatement(array());
     $this->_adapter->appendStatementToStack($stmt2);
     $this->assertSame($stmt2, $this->_adapter->query("foo"));
     $this->assertSame($stmt1, $this->_adapter->query("foo"));
 }
示例#3
0
    public function testFetchObject_ClassNotExists_ThrowsException()
    {
        $this->setExpectedException("Zend\Db\Statement\Exception");

        $row = array("foo" => "bar", "bar" => "baz");

        $stmt = new Test\DbStatement();
        $stmt->append($row);

        $object = $stmt->fetchObject("anInvalidClassName");
    }