# Coverage for Doctrine_Adapter_Statement_Mock

Back to coverage report

1 | <?php
2 | /*
3 | * $Id: Mock.php 2963 2007-10-21 06:23:59Z Jonathan.Wage $
4 | *
5 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
6 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
7 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
8 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
9 | * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
10 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
11 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
12 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
13 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
14 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
15 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
16 | *
17 | * This software consists of voluntary contributions made by many individuals
18 | * and is licensed under the LGPL. For more information, see
19 | * <http://www.phpdoctrine.org>.
20 | */
21 |
22 | /**
23 | * Doctrine_Adapter_Statement_Mock
24 | * This class is used for special testing purposes.
25 | *
26 | * @package Doctrine
27 | * @subpackage Adapter
28 | * @author Konsta Vesterinen <kvesteri@cc.hut.fi>
29 | * @license http://www.opensource.org/licenses/lgpl-license.php LGPL
30 | * @link www.phpdoctrine.org
31 | * @since 1.0
32 | * @version $Revision: 2963 $
33 | */
34 | class Doctrine_Adapter_Statement_Mock implements Doctrine_Adapter_Statement_Interface
35 | {
36 | private $mock;
37 |
38 | public $queryString;
39 |
40 | public function __construct($mock)
41 | {
42 | $this->mock = $mock;
43 | }
44 |
45 | /**
46 | * bindColumn
47 | * Bind a column to a PHP variable
48 | *
49 | * @param mixed $column Number of the column (1-indexed) or name of the column in the result set.
50 | * If using the column name, be aware that the name should match
51 | * the case of the column, as returned by the driver.
52 | * @param string $param Name of the PHP variable to which the column will be bound.
53 | * @param integer $type Data type of the parameter, specified by the Doctrine::PARAM_* constants.
54 | * @return boolean Returns TRUE on success or FALSE on failure
55 | */
56 | public function bindColumn($column, $param, $type = null)
57 | {
58 |
59 | }
60 |
61 | /**
62 | * bindValue
63 | * Binds a value to a corresponding named or question mark
64 | * placeholder in the SQL statement that was use to prepare the statement.
65 | *
66 | * @param mixed $param Parameter identifier. For a prepared statement using named placeholders,
67 | * this will be a parameter name of the form :name. For a prepared statement
68 | * using question mark placeholders, this will be the 1-indexed position of the parameter
69 | *
70 | * @param mixed $value The value to bind to the parameter.
71 | * @param integer $type Explicit data type for the parameter using the Doctrine::PARAM_* constants.
72 | *
73 | * @return boolean Returns TRUE on success or FALSE on failure.
74 | */
75 | public function bindValue($param, $value, $type = null)
76 | {
77 |
78 | }
79 |
80 | /**
81 | * bindParam
82 | * Binds a PHP variable to a corresponding named or question mark placeholder in the
83 | * SQL statement that was use to prepare the statement. Unlike Doctrine_Adapter_Statement_Interface->bindValue(),
84 | * the variable is bound as a reference and will only be evaluated at the time
85 | * that Doctrine_Adapter_Statement_Interface->execute() is called.
86 | *
87 | * Most parameters are input parameters, that is, parameters that are
88 | * used in a read-only fashion to build up the query. Some drivers support the invocation
89 | * of stored procedures that return data as output parameters, and some also as input/output
90 | * parameters that both send in data and are updated to receive it.
91 | *
92 | * @param mixed $param Parameter identifier. For a prepared statement using named placeholders,
93 | * this will be a parameter name of the form :name. For a prepared statement
94 | * using question mark placeholders, this will be the 1-indexed position of the parameter
95 | *
96 | * @param mixed $variable Name of the PHP variable to bind to the SQL statement parameter.
97 | *
98 | * @param integer $type Explicit data type for the parameter using the Doctrine::PARAM_* constants. To return
99 | * an INOUT parameter from a stored procedure, use the bitwise OR operator to set the
100 | * Doctrine::PARAM_INPUT_OUTPUT bits for the data_type parameter.
101 | *
102 | * @param integer $length Length of the data type. To indicate that a parameter is an OUT parameter
103 | * from a stored procedure, you must explicitly set the length.
104 | * @param mixed $driverOptions
105 | * @return boolean Returns TRUE on success or FALSE on failure.
106 | */
107 | public function bindParam($column, &$variable, $type = null, $length = null, $driverOptions = array())
108 | {
109 |
110 | }
111 |
112 | /**
113 | * closeCursor
114 | * Closes the cursor, enabling the statement to be executed again.
115 | *
116 | * @return boolean Returns TRUE on success or FALSE on failure.
117 | */
118 | public function closeCursor()
119 | {
120 | return true;
121 | }
122 |
123 | /**
124 | * columnCount
125 | * Returns the number of columns in the result set
126 | *
127 | * @return integer Returns the number of columns in the result set represented
128 | * by the Doctrine_Adapter_Statement_Interface object. If there is no result set,
129 | * this method should return 0.
130 | */
131 | public function columnCount()
132 | {
133 | return 0;
134 | }
135 |
136 | /**
137 | * errorCode
138 | * Fetch the SQLSTATE associated with the last operation on the statement handle
139 | *
140 | * @see Doctrine_Adapter_Interface::errorCode()
141 | * @return string error code string
142 | */
143 | public function errorCode()
144 | {
145 | return array();
146 | }
147 |
148 | /**
149 | * errorInfo
150 | * Fetch extended error information associated with the last operation on the statement handle
151 | *
152 | * @see Doctrine_Adapter_Interface::errorInfo()
153 | * @return array error info array
154 | */
155 | public function errorInfo()
156 | {
157 | return array();
158 | }
159 |
160 | /**
161 | * fetch
162 | *
163 | * @see Doctrine::FETCH_* constants
164 | * @param integer $fetchStyle Controls how the next row will be returned to the caller.
165 | * This value must be one of the Doctrine::FETCH_* constants,
166 | * defaulting to Doctrine::FETCH_BOTH
167 | *
168 | * @param integer $cursorOrientation For a PDOStatement object representing a scrollable cursor,
169 | * this value determines which row will be returned to the caller.
170 | * This value must be one of the Doctrine::FETCH_ORI_* constants, defaulting to
171 | * Doctrine::FETCH_ORI_NEXT. To request a scrollable cursor for your
172 | * Doctrine_Adapter_Statement_Interface object,
173 | * you must set the Doctrine::ATTR_CURSOR attribute to Doctrine::CURSOR_SCROLL when you
174 | * prepare the SQL statement with Doctrine_Adapter_Interface->prepare().
175 | *
176 | * @param integer $cursorOffset For a Doctrine_Adapter_Statement_Interface object representing a scrollable cursor for which the
177 | * $cursorOrientation parameter is set to Doctrine::FETCH_ORI_ABS, this value specifies
178 | * the absolute number of the row in the result set that shall be fetched.
179 | *
180 | * For a Doctrine_Adapter_Statement_Interface object representing a scrollable cursor for
181 | * which the $cursorOrientation parameter is set to Doctrine::FETCH_ORI_REL, this value
182 | * specifies the row to fetch relative to the cursor position before
183 | * Doctrine_Adapter_Statement_Interface->fetch() was called.
184 | *
185 | * @return mixed
186 | */
187 | public function fetch($fetchStyle = Doctrine::FETCH_BOTH,
188 | $cursorOrientation = Doctrine::FETCH_ORI_NEXT,
189 | $cursorOffset = null)
190 | {
191 | return array();
192 | }
193 |
194 | /**
195 | * fetchAll
196 | * Returns an array containing all of the result set rows
197 | *
198 | * @param integer $fetchStyle Controls how the next row will be returned to the caller.
199 | * This value must be one of the Doctrine::FETCH_* constants,
200 | * defaulting to Doctrine::FETCH_BOTH
201 | *
202 | * @param integer $columnIndex Returns the indicated 0-indexed column when the value of $fetchStyle is
203 | * Doctrine::FETCH_COLUMN. Defaults to 0.
204 | *
205 | * @return array
206 | */
207 | public function fetchAll($fetchMode = Doctrine::FETCH_BOTH)
208 | {
209 | return array();
210 | }
211 |
212 | /**
213 | * execute
214 | * Executes a prepared statement
215 | *
216 | * If the prepared statement included parameter markers, you must either:
217 | * call PDOStatement->bindParam() to bind PHP variables to the parameter markers:
218 | * bound variables pass their value as input and receive the output value,
219 | * if any, of their associated parameter markers or pass an array of input-only
220 | * parameter values
221 | *
222 | *
223 | * @param array $params An array of values with as many elements as there are
224 | * bound parameters in the SQL statement being executed.
225 | * @return boolean Returns TRUE on success or FALSE on failure.
226 | */
227 | public function execute($params = null)
228 | {
229 | if (is_object($this->mock)) {
230 | $this->mock->addQuery($this->queryString);
231 | }
232 | return true;
233 | }
234 |
235 | /**
236 | * fetchColumn
237 | * Returns a single column from the next row of a
238 | * result set or FALSE if there are no more rows.
239 | *
240 | * @param integer $columnIndex 0-indexed number of the column you wish to retrieve from the row. If no
241 | * value is supplied, Doctrine_Adapter_Statement_Interface->fetchColumn()
242 | * fetches the first column.
243 | *
244 | * @return string returns a single column in the next row of a result set.
245 | */
246 | public function fetchColumn($columnIndex = 0)
247 | {
248 | return 0;
249 | }
250 |
251 | /**
252 | * fetchObject
253 | * Fetches the next row and returns it as an object.
254 | *
255 | * Fetches the next row and returns it as an object. This function is an alternative to
256 | * Doctrine_Adapter_Statement_Interface->fetch() with Doctrine::FETCH_CLASS or Doctrine::FETCH_OBJ style.
257 | *
258 | * @param string $className Name of the created class, defaults to stdClass.
259 | * @param array $args Elements of this array are passed to the constructor.
260 | *
261 | * @return mixed an instance of the required class with property names that correspond
262 | * to the column names or FALSE in case of an error.
263 | */
264 | public function fetchObject($className = 'stdClass', $args = array())
265 | {
266 | return new $className();
267 | }
268 |
269 | /**
270 | * nextRowset
271 | * Advances to the next rowset in a multi-rowset statement handle
272 | *
273 | * Some database servers support stored procedures that return more than one rowset
274 | * (also known as a result set). The nextRowset() method enables you to access the second
275 | * and subsequent rowsets associated with a PDOStatement object. Each rowset can have a
276 | * different set of columns from the preceding rowset.
277 | *
278 | * @return boolean Returns TRUE on success or FALSE on failure.
279 | */
280 | public function nextRowset()
281 | {
282 | return true;
283 | }
284 |
285 | /**
286 | * rowCount
287 | * rowCount() returns the number of rows affected by the last DELETE, INSERT, or UPDATE statement
288 | * executed by the corresponding object.
289 | *
290 | * If the last SQL statement executed by the associated Statement object was a SELECT statement,
291 | * some databases may return the number of rows returned by that statement. However,
292 | * this behaviour is not guaranteed for all databases and should not be
293 | * relied on for portable applications.
294 | *
295 | * @return integer Returns the number of rows.
296 | */
297 | public function rowCount()
298 | {
299 | return 0;
300 | }
301 |
302 | /**
303 | * getColumnMeta
304 | * Returns metadata for a column in a result set
305 | *
306 | * @param integer $column The 0-indexed column in the result set.
307 | *
308 | * @return array Associative meta data array with the following structure:
309 | *
310 | * native_type The PHP native type used to represent the column value.
311 | * driver:decl_ type The SQL type used to represent the column value in the database. If the column in the result set is the result of a function, this value is not returned by PDOStatement->getColumnMeta().
312 | * flags Any flags set for this column.
313 | * name The name of this column as returned by the database.
314 | * len The length of this column. Normally -1 for types other than floating point decimals.
315 | * precision The numeric precision of this column. Normally 0 for types other than floating point decimals.
316 | * pdo_type The type of this column as represented by the PDO::PARAM_* constants.
317 | */
318 | public function getColumnMeta($column)
319 | { }
320 | /**
321 | * getAttribute
322 | * Retrieve a statement attribute
323 | *
324 | * @param integer $attribute
325 | * @see Doctrine::ATTR_* constants
326 | * @return mixed the attribute value
327 | */
328 | public function getAttribute($attribute)
329 | { }
330 | /**
331 | * setAttribute
332 | * Set a statement attribute
333 | *
334 | * @param integer $attribute
335 | * @param mixed $value the value of given attribute
336 | * @return boolean Returns TRUE on success or FALSE on failure.
337 | */
338 | public function setAttribute($attribute, $value)
339 | { }
340 | /**
341 | * setFetchMode
342 | * Set the default fetch mode for this statement
343 | *
344 | * @param integer $mode The fetch mode must be one of the Doctrine::FETCH_* constants.
345 | * @return boolean Returns 1 on success or FALSE on failure.
346 | */
347 | public function setFetchMode($mode, $arg1 = null, $arg2 = null)
348 | { }
349 | }