3 namespace Doctrine\Tests\Mocks;
6 * This class is a mock of the Statement interface that can be passed in to the Hydrator
7 * to test the hydration standalone with faked result sets.
9 * @author Roman Borschel <roman@code-factory.org>
11 class HydratorMockStatement implements \IteratorAggregate, \Doctrine\DBAL\Driver\Statement
16 * Creates a new mock statement that will serve the provided fake result set to clients.
18 * @param array $resultSet The faked SQL result set.
20 public function __construct(array $resultSet)
22 $this->_resultSet = $resultSet;
26 * Fetches all rows from the result set.
30 public function fetchAll($fetchStyle = null, $columnIndex = null, array $ctorArgs = null)
32 return $this->_resultSet;
35 public function fetchColumn($columnNumber = 0)
37 $row = current($this->_resultSet);
38 if ( ! is_array($row)) return false;
39 $val = array_shift($row);
40 return $val !== null ? $val : false;
44 * Fetches the next row in the result set.
47 public function fetch($fetchStyle = null)
49 $current = current($this->_resultSet);
50 next($this->_resultSet);
55 * Closes the cursor, enabling the statement to be executed again.
59 public function closeCursor()
64 public function setResultSet(array $resultSet)
67 $this->_resultSet = $resultSet;
70 public function bindColumn($column, &$param, $type = null)
74 public function bindValue($param, $value, $type = null)
78 public function bindParam($column, &$variable, $type = null, $length = null, $driverOptions = array())
82 public function columnCount()
86 public function errorCode()
90 public function errorInfo()
94 public function execute($params = array())
98 public function rowCount()
102 public function getIterator()
104 return $this->_resultSet;
107 public function setFetchMode($fetchStyle, $arg2 = null, $arg3 = null)