1
0
Fork 0
mirror of synced 2025-04-03 13:23:37 +03:00

Forward compatibility with DBAL master

This commit is contained in:
Benjamin Eberlei 2011-11-12 12:56:44 +01:00
parent a14ba1e561
commit 450d92872a
3 changed files with 45 additions and 28 deletions

View file

@ -8,7 +8,7 @@ class ConnectionMock extends \Doctrine\DBAL\Connection
private $_platformMock; private $_platformMock;
private $_lastInsertId = 0; private $_lastInsertId = 0;
private $_inserts = array(); private $_inserts = array();
public function __construct(array $params, $driver, $config = null, $eventManager = null) public function __construct(array $params, $driver, $config = null, $eventManager = null)
{ {
$this->_platformMock = new DatabasePlatformMock(); $this->_platformMock = new DatabasePlatformMock();
@ -18,7 +18,7 @@ class ConnectionMock extends \Doctrine\DBAL\Connection
// Override possible assignment of platform to database platform mock // Override possible assignment of platform to database platform mock
$this->_platform = $this->_platformMock; $this->_platform = $this->_platformMock;
} }
/** /**
* @override * @override
*/ */
@ -26,15 +26,15 @@ class ConnectionMock extends \Doctrine\DBAL\Connection
{ {
return $this->_platformMock; return $this->_platformMock;
} }
/** /**
* @override * @override
*/ */
public function insert($tableName, array $data) public function insert($tableName, array $data, array $types = array())
{ {
$this->_inserts[$tableName][] = $data; $this->_inserts[$tableName][] = $data;
} }
/** /**
* @override * @override
*/ */
@ -50,7 +50,7 @@ class ConnectionMock extends \Doctrine\DBAL\Connection
{ {
return $this->_fetchOneResult; return $this->_fetchOneResult;
} }
/** /**
* @override * @override
*/ */
@ -61,29 +61,29 @@ class ConnectionMock extends \Doctrine\DBAL\Connection
} }
return $input; return $input;
} }
/* Mock API */ /* Mock API */
public function setFetchOneResult($fetchOneResult) public function setFetchOneResult($fetchOneResult)
{ {
$this->_fetchOneResult = $fetchOneResult; $this->_fetchOneResult = $fetchOneResult;
} }
public function setDatabasePlatform($platform) public function setDatabasePlatform($platform)
{ {
$this->_platformMock = $platform; $this->_platformMock = $platform;
} }
public function setLastInsertId($id) public function setLastInsertId($id)
{ {
$this->_lastInsertId = $id; $this->_lastInsertId = $id;
} }
public function getInserts() public function getInserts()
{ {
return $this->_inserts; return $this->_inserts;
} }
public function reset() public function reset()
{ {
$this->_inserts = array(); $this->_inserts = array();

View file

@ -57,7 +57,7 @@ class DatabasePlatformMock extends \Doctrine\DBAL\Platforms\AbstractPlatform
/** @override */ /** @override */
public function getVarcharTypeDeclarationSQL(array $field) {} public function getVarcharTypeDeclarationSQL(array $field) {}
/** @override */ /** @override */
public function getClobTypeDeclarationSQL(array $field) {} public function getClobTypeDeclarationSQL(array $field) {}
@ -85,6 +85,13 @@ class DatabasePlatformMock extends \Doctrine\DBAL\Platforms\AbstractPlatform
protected function initializeDoctrineTypeMappings() protected function initializeDoctrineTypeMappings()
{ {
}
/**
* Gets the SQL Snippet used to declare a BLOB column type.
*/
public function getBlobTypeDeclarationSQL(array $field)
{
throw DBALException::notSupported(__METHOD__);
} }
} }

View file

@ -8,10 +8,10 @@ namespace Doctrine\Tests\Mocks;
* *
* @author Roman Borschel <roman@code-factory.org> * @author Roman Borschel <roman@code-factory.org>
*/ */
class HydratorMockStatement implements \Doctrine\DBAL\Driver\Statement class HydratorMockStatement implements \IteratorAggregate, \Doctrine\DBAL\Driver\Statement
{ {
private $_resultSet; private $_resultSet;
/** /**
* Creates a new mock statement that will serve the provided fake result set to clients. * Creates a new mock statement that will serve the provided fake result set to clients.
* *
@ -21,7 +21,7 @@ class HydratorMockStatement implements \Doctrine\DBAL\Driver\Statement
{ {
$this->_resultSet = $resultSet; $this->_resultSet = $resultSet;
} }
/** /**
* Fetches all rows from the result set. * Fetches all rows from the result set.
* *
@ -31,7 +31,7 @@ class HydratorMockStatement implements \Doctrine\DBAL\Driver\Statement
{ {
return $this->_resultSet; return $this->_resultSet;
} }
public function fetchColumn($columnNumber = 0) public function fetchColumn($columnNumber = 0)
{ {
$row = current($this->_resultSet); $row = current($this->_resultSet);
@ -39,10 +39,10 @@ class HydratorMockStatement implements \Doctrine\DBAL\Driver\Statement
$val = array_shift($row); $val = array_shift($row);
return $val !== null ? $val : false; return $val !== null ? $val : false;
} }
/** /**
* Fetches the next row in the result set. * Fetches the next row in the result set.
* *
*/ */
public function fetch($fetchStyle = null) public function fetch($fetchStyle = null)
{ {
@ -50,7 +50,7 @@ class HydratorMockStatement implements \Doctrine\DBAL\Driver\Statement
next($this->_resultSet); next($this->_resultSet);
return $current; return $current;
} }
/** /**
* Closes the cursor, enabling the statement to be executed again. * Closes the cursor, enabling the statement to be executed again.
* *
@ -60,13 +60,13 @@ class HydratorMockStatement implements \Doctrine\DBAL\Driver\Statement
{ {
return true; return true;
} }
public function setResultSet(array $resultSet) public function setResultSet(array $resultSet)
{ {
reset($resultSet); reset($resultSet);
$this->_resultSet = $resultSet; $this->_resultSet = $resultSet;
} }
public function bindColumn($column, &$param, $type = null) public function bindColumn($column, &$param, $type = null)
{ {
} }
@ -78,7 +78,7 @@ class HydratorMockStatement implements \Doctrine\DBAL\Driver\Statement
public function bindParam($column, &$variable, $type = null, $length = null, $driverOptions = array()) public function bindParam($column, &$variable, $type = null, $length = null, $driverOptions = array())
{ {
} }
public function columnCount() public function columnCount()
{ {
} }
@ -86,16 +86,26 @@ class HydratorMockStatement implements \Doctrine\DBAL\Driver\Statement
public function errorCode() public function errorCode()
{ {
} }
public function errorInfo() public function errorInfo()
{ {
} }
public function execute($params = array()) public function execute($params = array())
{ {
} }
public function rowCount() public function rowCount()
{ {
} }
public function getIterator()
{
return $this->_resultSet;
}
public function setFetchMode($fetchMode)
{
}
} }