1
0
mirror of synced 2024-12-14 23:26:04 +03:00
doctrine2/tests/Doctrine/Tests/Mocks/HydratorMockStatement.php

111 lines
2.3 KiB
PHP
Raw Normal View History

2009-01-04 19:15:32 +03:00
<?php
namespace Doctrine\Tests\Mocks;
/**
* This class is a mock of the Statement interface that can be passed in to the Hydrator
* to test the hydration standalone with faked result sets.
*
* @author Roman Borschel <roman@code-factory.org>
*/
2011-11-12 15:56:44 +04:00
class HydratorMockStatement implements \IteratorAggregate, \Doctrine\DBAL\Driver\Statement
{
2011-11-12 15:56:44 +04:00
private $_resultSet;
/**
* Creates a new mock statement that will serve the provided fake result set to clients.
*
* @param array $resultSet The faked SQL result set.
*/
public function __construct(array $resultSet)
{
$this->_resultSet = $resultSet;
}
2011-11-12 15:56:44 +04:00
/**
* Fetches all rows from the result set.
*
* @return array
*/
public function fetchAll($fetchStyle = null, $columnIndex = null, array $ctorArgs = null)
{
return $this->_resultSet;
}
2011-11-12 15:56:44 +04:00
public function fetchColumn($columnNumber = 0)
{
$row = current($this->_resultSet);
if ( ! is_array($row)) return false;
$val = array_shift($row);
return $val !== null ? $val : false;
}
2011-11-12 15:56:44 +04:00
/**
* Fetches the next row in the result set.
2011-11-12 15:56:44 +04:00
*
*/
public function fetch($fetchStyle = null)
{
$current = current($this->_resultSet);
next($this->_resultSet);
return $current;
}
2011-11-12 15:56:44 +04:00
/**
* Closes the cursor, enabling the statement to be executed again.
*
* @return boolean
*/
public function closeCursor()
{
return true;
}
2011-11-12 15:56:44 +04:00
public function setResultSet(array $resultSet)
{
reset($resultSet);
$this->_resultSet = $resultSet;
}
2011-11-12 15:56:44 +04:00
public function bindColumn($column, &$param, $type = null)
{
}
public function bindValue($param, $value, $type = null)
{
}
public function bindParam($column, &$variable, $type = null, $length = null, $driverOptions = array())
{
}
2011-11-12 15:56:44 +04:00
public function columnCount()
{
}
public function errorCode()
{
}
2011-11-12 15:56:44 +04:00
public function errorInfo()
{
}
2011-11-12 15:56:44 +04:00
public function execute($params = array())
{
}
2011-11-12 15:56:44 +04:00
public function rowCount()
{
2011-11-12 15:56:44 +04:00
}
public function getIterator()
{
return $this->_resultSet;
}
public function setFetchMode($fetchMode)
{
}
}