current_row == 5) { return false; } else { return array('name' => 'Fred', 'age' => 10, 'id' => ++$this->current_row); } } } /** * Another mock PDOStatement class, used for testing multiple connections */ class MockDifferentPDOStatement extends MockPDOStatement { } /** * * Mock database class implementing a subset * of the PDO API. * */ class MockPDO extends PDO { /** * Return a dummy PDO statement */ public function prepare($statement, $driver_options=array()) { $this->last_query = new MockPDOStatement($statement); return $this->last_query; } } /** * A different mock database class, for testing multiple connections * Mock database class implementing a subset of the PDO API. */ class MockDifferentPDO extends MockPDO { /** * Return a dummy PDO statement */ public function prepare($statement, $driver_options = array()) { $this->last_query = new MockDifferentPDOStatement($statement); return $this->last_query; } } class MockMsSqlPDO extends MockPDO { public $fake_driver = 'mssql'; /** * If we are asking for the name of the driver, check if a fake one * has been set. */ public function getAttribute($attribute) { if ($attribute == self::ATTR_DRIVER_NAME) { if (!is_null($this->fake_driver)) { return $this->fake_driver; } } return parent::getAttribute($attribute); } }