/**
  * Create a Select statement which returns the given array of rows.
  *
  * @param array $rows
  * @return Zend_Test_DbStatement
  */
 public static function createSelectStatement(array $rows = array())
 {
     $stmt = new Zend_Test_DbStatement();
     foreach ($rows as $row) {
         $stmt->append($row);
     }
     return $stmt;
 }
Пример #2
0
 public function testDataIsLoadedOnlyOnce()
 {
     $fixtureSql = "SELECT * FROM foo";
     $statementMock = new Zend_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 Zend_Test_PHPUnit_Db_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);
 }
 public function testFetchObject_ClassNotExists_ThrowsException()
 {
     $this->setExpectedException("Zend_Db_Statement_Exception");
     $row = array("foo" => "bar", "bar" => "baz");
     $stmt = new Zend_Test_DbStatement();
     $stmt->append($row);
     $object = $stmt->fetchObject("anInvalidClassName");
 }