Rajout de doctrine/orm
[zf2.biz/galerie.git] / vendor / doctrine / orm / tests / Doctrine / Tests / Mocks / HydratorMockStatement.php
1 <?php
2
3 namespace Doctrine\Tests\Mocks;
4
5 /**
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.
8  *
9  * @author  Roman Borschel <roman@code-factory.org>
10  */
11 class HydratorMockStatement implements \IteratorAggregate, \Doctrine\DBAL\Driver\Statement
12 {
13     private $_resultSet;
14
15     /**
16      * Creates a new mock statement that will serve the provided fake result set to clients.
17      *
18      * @param array $resultSet  The faked SQL result set.
19      */
20     public function __construct(array $resultSet)
21     {
22         $this->_resultSet = $resultSet;
23     }
24
25     /**
26      * Fetches all rows from the result set.
27      *
28      * @return array
29      */
30     public function fetchAll($fetchStyle = null, $columnIndex = null, array $ctorArgs = null)
31     {
32         return $this->_resultSet;
33     }
34
35     public function fetchColumn($columnNumber = 0)
36     {
37         $row = current($this->_resultSet);
38         if ( ! is_array($row)) return false;
39         $val = array_shift($row);
40         return $val !== null ? $val : false;
41     }
42
43     /**
44      * Fetches the next row in the result set.
45      *
46      */
47     public function fetch($fetchStyle = null)
48     {
49         $current = current($this->_resultSet);
50         next($this->_resultSet);
51         return $current;
52     }
53
54     /**
55      * Closes the cursor, enabling the statement to be executed again.
56      *
57      * @return boolean
58      */
59     public function closeCursor()
60     {
61         return true;
62     }
63
64     public function setResultSet(array $resultSet)
65     {
66         reset($resultSet);
67         $this->_resultSet = $resultSet;
68     }
69
70     public function bindColumn($column, &$param, $type = null)
71     {
72     }
73
74     public function bindValue($param, $value, $type = null)
75     {
76     }
77
78     public function bindParam($column, &$variable, $type = null, $length = null, $driverOptions = array())
79     {
80     }
81
82     public function columnCount()
83     {
84     }
85
86     public function errorCode()
87     {
88     }
89
90     public function errorInfo()
91     {
92     }
93
94     public function execute($params = array())
95     {
96     }
97
98     public function rowCount()
99     {
100     }
101
102     public function getIterator()
103     {
104         return $this->_resultSet;
105     }
106
107     public function setFetchMode($fetchStyle, $arg2 = null, $arg3 = null)
108     {
109
110     }
111 }