Fixed documentation for Doctrine\Tests\Mocks
This commit is contained in:
parent
76f2ba50eb
commit
c405f6d3f6
@ -2,13 +2,18 @@
|
||||
|
||||
namespace Doctrine\Tests\Mocks;
|
||||
|
||||
/**
|
||||
* Mock class for ClassMetadata.
|
||||
*/
|
||||
class ClassMetadataMock extends \Doctrine\ORM\Mapping\ClassMetadata
|
||||
{
|
||||
/* Mock API */
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function setIdGeneratorType($type)
|
||||
{
|
||||
$this->_generatorType = $type;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -2,14 +2,42 @@
|
||||
|
||||
namespace Doctrine\Tests\Mocks;
|
||||
|
||||
/**
|
||||
* Mock class for Connection.
|
||||
*/
|
||||
class ConnectionMock extends \Doctrine\DBAL\Connection
|
||||
{
|
||||
/**
|
||||
* @var mixed
|
||||
*/
|
||||
private $_fetchOneResult;
|
||||
|
||||
/**
|
||||
* @var DatabasePlatformMock
|
||||
*/
|
||||
private $_platformMock;
|
||||
|
||||
/**
|
||||
* @var int
|
||||
*/
|
||||
private $_lastInsertId = 0;
|
||||
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
private $_inserts = array();
|
||||
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
private $_executeUpdates = array();
|
||||
|
||||
/**
|
||||
* @param array $params
|
||||
* @param \Doctrine\DBAL\Driver $driver
|
||||
* @param \Doctrine\DBAL\Configuration|null $config
|
||||
* @param \Doctrine\Common\EventManager|null $eventManager
|
||||
*/
|
||||
public function __construct(array $params, $driver, $config = null, $eventManager = null)
|
||||
{
|
||||
$this->_platformMock = new DatabasePlatformMock();
|
||||
@ -21,7 +49,7 @@ class ConnectionMock extends \Doctrine\DBAL\Connection
|
||||
}
|
||||
|
||||
/**
|
||||
* @override
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getDatabasePlatform()
|
||||
{
|
||||
@ -29,7 +57,7 @@ class ConnectionMock extends \Doctrine\DBAL\Connection
|
||||
}
|
||||
|
||||
/**
|
||||
* @override
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function insert($tableName, array $data, array $types = array())
|
||||
{
|
||||
@ -37,7 +65,7 @@ class ConnectionMock extends \Doctrine\DBAL\Connection
|
||||
}
|
||||
|
||||
/**
|
||||
* @override
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function executeUpdate($query, array $params = array(), array $types = array())
|
||||
{
|
||||
@ -45,7 +73,7 @@ class ConnectionMock extends \Doctrine\DBAL\Connection
|
||||
}
|
||||
|
||||
/**
|
||||
* @override
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function lastInsertId($seqName = null)
|
||||
{
|
||||
@ -53,7 +81,7 @@ class ConnectionMock extends \Doctrine\DBAL\Connection
|
||||
}
|
||||
|
||||
/**
|
||||
* @override
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function fetchColumn($statement, array $params = array(), $colnum = 0)
|
||||
{
|
||||
@ -61,7 +89,7 @@ class ConnectionMock extends \Doctrine\DBAL\Connection
|
||||
}
|
||||
|
||||
/**
|
||||
* @override
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function quote($input, $type = null)
|
||||
{
|
||||
@ -73,34 +101,58 @@ class ConnectionMock extends \Doctrine\DBAL\Connection
|
||||
|
||||
/* Mock API */
|
||||
|
||||
/**
|
||||
* @param mixed $fetchOneResult
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function setFetchOneResult($fetchOneResult)
|
||||
{
|
||||
$this->_fetchOneResult = $fetchOneResult;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param \Doctrine\DBAL\Platforms\AbstractPlatform $platform
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function setDatabasePlatform($platform)
|
||||
{
|
||||
$this->_platformMock = $platform;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $id
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function setLastInsertId($id)
|
||||
{
|
||||
$this->_lastInsertId = $id;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function getInserts()
|
||||
{
|
||||
return $this->_inserts;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function getExecuteUpdates()
|
||||
{
|
||||
return $this->_executeUpdates;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function reset()
|
||||
{
|
||||
$this->_inserts = array();
|
||||
$this->_lastInsertId = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -2,24 +2,42 @@
|
||||
|
||||
namespace Doctrine\Tests\Mocks;
|
||||
|
||||
/**
|
||||
* Mock class for DatabasePlatform.
|
||||
*/
|
||||
class DatabasePlatformMock extends \Doctrine\DBAL\Platforms\AbstractPlatform
|
||||
{
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $_sequenceNextValSql = "";
|
||||
|
||||
/**
|
||||
* @var bool
|
||||
*/
|
||||
private $_prefersIdentityColumns = true;
|
||||
|
||||
/**
|
||||
* @var bool
|
||||
*/
|
||||
private $_prefersSequences = false;
|
||||
|
||||
/**
|
||||
* @override
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getNativeDeclaration(array $field) {}
|
||||
public function getNativeDeclaration(array $field)
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* @override
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getPortableDeclaration(array $field) {}
|
||||
public function getPortableDeclaration(array $field)
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* @override
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function prefersIdentityColumns()
|
||||
{
|
||||
@ -27,71 +45,122 @@ class DatabasePlatformMock extends \Doctrine\DBAL\Platforms\AbstractPlatform
|
||||
}
|
||||
|
||||
/**
|
||||
* @override
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function prefersSequences()
|
||||
{
|
||||
return $this->_prefersSequences;
|
||||
}
|
||||
|
||||
/** @override */
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getSequenceNextValSQL($sequenceName)
|
||||
{
|
||||
return $this->_sequenceNextValSql;
|
||||
}
|
||||
|
||||
/** @override */
|
||||
public function getBooleanTypeDeclarationSQL(array $field) {}
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getBooleanTypeDeclarationSQL(array $field)
|
||||
{
|
||||
}
|
||||
|
||||
/** @override */
|
||||
public function getIntegerTypeDeclarationSQL(array $field) {}
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getIntegerTypeDeclarationSQL(array $field)
|
||||
{
|
||||
}
|
||||
|
||||
/** @override */
|
||||
public function getBigIntTypeDeclarationSQL(array $field) {}
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getBigIntTypeDeclarationSQL(array $field)
|
||||
{
|
||||
}
|
||||
|
||||
/** @override */
|
||||
public function getSmallIntTypeDeclarationSQL(array $field) {}
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getSmallIntTypeDeclarationSQL(array $field)
|
||||
{
|
||||
}
|
||||
|
||||
/** @override */
|
||||
protected function _getCommonIntegerTypeDeclarationSQL(array $columnDef) {}
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function _getCommonIntegerTypeDeclarationSQL(array $columnDef)
|
||||
{
|
||||
}
|
||||
|
||||
/** @override */
|
||||
public function getVarcharTypeDeclarationSQL(array $field) {}
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getVarcharTypeDeclarationSQL(array $field)
|
||||
{
|
||||
}
|
||||
|
||||
/** @override */
|
||||
public function getClobTypeDeclarationSQL(array $field) {}
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getClobTypeDeclarationSQL(array $field)
|
||||
{
|
||||
}
|
||||
|
||||
/* MOCK API */
|
||||
|
||||
/**
|
||||
* @param bool $bool
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function setPrefersIdentityColumns($bool)
|
||||
{
|
||||
$this->_prefersIdentityColumns = $bool;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param bool $bool
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function setPrefersSequences($bool)
|
||||
{
|
||||
$this->_prefersSequences = $bool;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $sql
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function setSequenceNextValSql($sql)
|
||||
{
|
||||
$this->_sequenceNextValSql = $sql;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getName()
|
||||
{
|
||||
return 'mock';
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function initializeDoctrineTypeMappings()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the SQL Snippet used to declare a BLOB column type.
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getBlobTypeDeclarationSQL(array $field)
|
||||
{
|
||||
throw DBALException::notSupported(__METHOD__);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -2,16 +2,79 @@
|
||||
|
||||
namespace Doctrine\Tests\Mocks;
|
||||
|
||||
/**
|
||||
* Mock class for DriverConnection.
|
||||
*/
|
||||
class DriverConnectionMock implements \Doctrine\DBAL\Driver\Connection
|
||||
{
|
||||
public function prepare($prepareString) {}
|
||||
public function query() { return new StatementMock; }
|
||||
public function quote($input, $type=\PDO::PARAM_STR) {}
|
||||
public function exec($statement) {}
|
||||
public function lastInsertId($name = null) {}
|
||||
public function beginTransaction() {}
|
||||
public function commit() {}
|
||||
public function rollBack() {}
|
||||
public function errorCode() {}
|
||||
public function errorInfo() {}
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function prepare($prepareString)
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function query()
|
||||
{
|
||||
return new StatementMock;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function quote($input, $type=\PDO::PARAM_STR)
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function exec($statement)
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function lastInsertId($name = null)
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function beginTransaction()
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function commit()
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function rollBack()
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function errorCode()
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function errorInfo()
|
||||
{
|
||||
}
|
||||
}
|
||||
|
@ -2,13 +2,24 @@
|
||||
|
||||
namespace Doctrine\Tests\Mocks;
|
||||
|
||||
|
||||
/**
|
||||
* Mock class for Driver.
|
||||
*/
|
||||
class DriverMock implements \Doctrine\DBAL\Driver
|
||||
{
|
||||
/**
|
||||
* @var \Doctrine\DBAL\Platforms\AbstractPlatform|null
|
||||
*/
|
||||
private $_platformMock;
|
||||
|
||||
/**
|
||||
* @var \Doctrine\DBAL\Schema\AbstractSchemaManager|null
|
||||
*/
|
||||
private $_schemaManagerMock;
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function connect(array $params, $username = null, $password = null, array $driverOptions = array())
|
||||
{
|
||||
return new DriverConnectionMock();
|
||||
@ -17,7 +28,10 @@ class DriverMock implements \Doctrine\DBAL\Driver
|
||||
/**
|
||||
* Constructs the Sqlite PDO DSN.
|
||||
*
|
||||
* @return string The DSN.
|
||||
* @param array $params
|
||||
*
|
||||
* @return string The DSN.
|
||||
*
|
||||
* @override
|
||||
*/
|
||||
protected function _constructPdoDsn(array $params)
|
||||
@ -26,7 +40,7 @@ class DriverMock implements \Doctrine\DBAL\Driver
|
||||
}
|
||||
|
||||
/**
|
||||
* @override
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getDatabasePlatform()
|
||||
{
|
||||
@ -37,11 +51,11 @@ class DriverMock implements \Doctrine\DBAL\Driver
|
||||
}
|
||||
|
||||
/**
|
||||
* @override
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getSchemaManager(\Doctrine\DBAL\Connection $conn)
|
||||
{
|
||||
if($this->_schemaManagerMock == null) {
|
||||
if ($this->_schemaManagerMock == null) {
|
||||
return new SchemaManagerMock($conn);
|
||||
} else {
|
||||
return $this->_schemaManagerMock;
|
||||
@ -50,23 +64,39 @@ class DriverMock implements \Doctrine\DBAL\Driver
|
||||
|
||||
/* MOCK API */
|
||||
|
||||
/**
|
||||
* @param \Doctrine\DBAL\Platforms\AbstractPlatform $platform
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function setDatabasePlatform(\Doctrine\DBAL\Platforms\AbstractPlatform $platform)
|
||||
{
|
||||
$this->_platformMock = $platform;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param \Doctrine\DBAL\Schema\AbstractSchemaManager $sm
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function setSchemaManager(\Doctrine\DBAL\Schema\AbstractSchemaManager $sm)
|
||||
{
|
||||
$this->_schemaManagerMock = $sm;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getName()
|
||||
{
|
||||
return 'mock';
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getDatabase(\Doctrine\DBAL\Connection $conn)
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -28,12 +28,23 @@ use Doctrine\ORM\Proxy\ProxyFactory;
|
||||
*/
|
||||
class EntityManagerMock extends \Doctrine\ORM\EntityManager
|
||||
{
|
||||
/**
|
||||
* @var \Doctrine\ORM\UnitOfWork|null
|
||||
*/
|
||||
private $_uowMock;
|
||||
|
||||
/**
|
||||
* @var \Doctrine\ORM\Proxy\ProxyFactory|null
|
||||
*/
|
||||
private $_proxyFactoryMock;
|
||||
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
private $_idGenerators = array();
|
||||
|
||||
/**
|
||||
* @override
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getUnitOfWork()
|
||||
{
|
||||
@ -45,18 +56,28 @@ class EntityManagerMock extends \Doctrine\ORM\EntityManager
|
||||
/**
|
||||
* Sets a (mock) UnitOfWork that will be returned when getUnitOfWork() is called.
|
||||
*
|
||||
* @param <type> $uow
|
||||
* @param \Doctrine\ORM\UnitOfWork $uow
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function setUnitOfWork($uow)
|
||||
{
|
||||
$this->_uowMock = $uow;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param \Doctrine\ORM\Proxy\ProxyFactory $proxyFactory
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function setProxyFactory($proxyFactory)
|
||||
{
|
||||
$this->_proxyFactoryMock = $proxyFactory;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \Doctrine\ORM\Proxy\ProxyFactory
|
||||
*/
|
||||
public function getProxyFactory()
|
||||
{
|
||||
return isset($this->_proxyFactoryMock) ? $this->_proxyFactoryMock : parent::getProxyFactory();
|
||||
@ -65,11 +86,7 @@ class EntityManagerMock extends \Doctrine\ORM\EntityManager
|
||||
/**
|
||||
* Mock factory method to create an EntityManager.
|
||||
*
|
||||
* @param unknown_type $conn
|
||||
* @param unknown_type $name
|
||||
* @param Doctrine_Configuration $config
|
||||
* @param Doctrine_EventManager $eventManager
|
||||
* @return Doctrine\ORM\EntityManager
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public static function create($conn, \Doctrine\ORM\Configuration $config = null,
|
||||
\Doctrine\Common\EventManager $eventManager = null)
|
||||
|
@ -7,17 +7,46 @@ namespace Doctrine\Tests\Mocks;
|
||||
*/
|
||||
class EntityPersisterMock extends \Doctrine\ORM\Persisters\BasicEntityPersister
|
||||
{
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
private $inserts = array();
|
||||
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
private $updates = array();
|
||||
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
private $deletes = array();
|
||||
|
||||
/**
|
||||
* @var int
|
||||
*/
|
||||
private $identityColumnValueCounter = 0;
|
||||
|
||||
/**
|
||||
* @var int|null
|
||||
*/
|
||||
private $mockIdGeneratorType;
|
||||
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
private $postInsertIds = array();
|
||||
|
||||
/**
|
||||
* @var bool
|
||||
*/
|
||||
private $existsCalled = false;
|
||||
|
||||
/**
|
||||
* @param <type> $entity
|
||||
* @return <type>
|
||||
* @param object $entity
|
||||
*
|
||||
* @return mixed
|
||||
*
|
||||
* @override
|
||||
*/
|
||||
public function insert($entity)
|
||||
@ -32,6 +61,11 @@ class EntityPersisterMock extends \Doctrine\ORM\Persisters\BasicEntityPersister
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param object $entity
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function addInsert($entity)
|
||||
{
|
||||
$this->inserts[] = $entity;
|
||||
@ -44,46 +78,75 @@ class EntityPersisterMock extends \Doctrine\ORM\Persisters\BasicEntityPersister
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function executeInserts()
|
||||
{
|
||||
return $this->postInsertIds;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $genType
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function setMockIdGeneratorType($genType)
|
||||
{
|
||||
$this->mockIdGeneratorType = $genType;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function update($entity)
|
||||
{
|
||||
$this->updates[] = $entity;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function exists($entity, array $extraConditions = array())
|
||||
{
|
||||
$this->existsCalled = true;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function delete($entity)
|
||||
{
|
||||
$this->deletes[] = $entity;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function getInserts()
|
||||
{
|
||||
return $this->inserts;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function getUpdates()
|
||||
{
|
||||
return $this->updates;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function getDeletes()
|
||||
{
|
||||
return $this->deletes;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function reset()
|
||||
{
|
||||
$this->existsCalled = false;
|
||||
@ -93,8 +156,11 @@ class EntityPersisterMock extends \Doctrine\ORM\Persisters\BasicEntityPersister
|
||||
$this->deletes = array();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function isExistsCalled()
|
||||
{
|
||||
return $this->existsCalled;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -10,12 +10,15 @@ namespace Doctrine\Tests\Mocks;
|
||||
*/
|
||||
class HydratorMockStatement implements \IteratorAggregate, \Doctrine\DBAL\Driver\Statement
|
||||
{
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
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.
|
||||
* @param array $resultSet The faked SQL result set.
|
||||
*/
|
||||
public function __construct(array $resultSet)
|
||||
{
|
||||
@ -25,6 +28,10 @@ class HydratorMockStatement implements \IteratorAggregate, \Doctrine\DBAL\Driver
|
||||
/**
|
||||
* Fetches all rows from the result set.
|
||||
*
|
||||
* @param int|null $fetchStyle
|
||||
* @param int|null $columnIndex
|
||||
* @param array|null $ctorArgs
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function fetchAll($fetchStyle = null, $columnIndex = null, array $ctorArgs = null)
|
||||
@ -32,6 +39,9 @@ class HydratorMockStatement implements \IteratorAggregate, \Doctrine\DBAL\Driver
|
||||
return $this->_resultSet;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function fetchColumn($columnNumber = 0)
|
||||
{
|
||||
$row = current($this->_resultSet);
|
||||
@ -41,8 +51,7 @@ class HydratorMockStatement implements \IteratorAggregate, \Doctrine\DBAL\Driver
|
||||
}
|
||||
|
||||
/**
|
||||
* Fetches the next row in the result set.
|
||||
*
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function fetch($fetchStyle = null)
|
||||
{
|
||||
@ -52,15 +61,18 @@ class HydratorMockStatement implements \IteratorAggregate, \Doctrine\DBAL\Driver
|
||||
}
|
||||
|
||||
/**
|
||||
* Closes the cursor, enabling the statement to be executed again.
|
||||
*
|
||||
* @return boolean
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function closeCursor()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $resultSet
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function setResultSet(array $resultSet)
|
||||
{
|
||||
reset($resultSet);
|
||||
@ -71,41 +83,67 @@ class HydratorMockStatement implements \IteratorAggregate, \Doctrine\DBAL\Driver
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function bindValue($param, $value, $type = null)
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function bindParam($column, &$variable, $type = null, $length = null, $driverOptions = array())
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function columnCount()
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function errorCode()
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function errorInfo()
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function execute($params = array())
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function rowCount()
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getIterator()
|
||||
{
|
||||
return $this->_resultSet;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function setFetchMode($fetchStyle, $arg2 = null, $arg3 = null)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -2,11 +2,15 @@
|
||||
|
||||
namespace Doctrine\Tests\Mocks;
|
||||
|
||||
/**
|
||||
* Mock class for IdentityGenerator.
|
||||
*/
|
||||
class IdentityIdGeneratorMock extends \Doctrine\ORM\Id\IdentityGenerator
|
||||
{
|
||||
private $_mockPostInsertId;
|
||||
|
||||
public function setMockPostInsertId($id) {
|
||||
public function setMockPostInsertId($id)
|
||||
{
|
||||
$this->_mockPostInsertId = $id;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -2,20 +2,31 @@
|
||||
|
||||
namespace Doctrine\Tests\Mocks;
|
||||
|
||||
/**
|
||||
* Mock class for MappingDriver.
|
||||
*/
|
||||
class MetadataDriverMock implements \Doctrine\Common\Persistence\Mapping\Driver\MappingDriver
|
||||
{
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function loadMetadataForClass($className, \Doctrine\Common\Persistence\Mapping\ClassMetadata $metadata)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function isTransient($className)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getAllClassNames()
|
||||
{
|
||||
return array();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -2,16 +2,16 @@
|
||||
|
||||
namespace Doctrine\Tests\Mocks;
|
||||
|
||||
/**
|
||||
* Mock class for TreeWalker.
|
||||
*/
|
||||
class MockTreeWalker extends \Doctrine\ORM\Query\TreeWalkerAdapter
|
||||
{
|
||||
/**
|
||||
* Gets an executor that can be used to execute the result of this walker.
|
||||
*
|
||||
* @return AbstractExecutor
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getExecutor($AST)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2,12 +2,23 @@
|
||||
|
||||
namespace Doctrine\Tests\Mocks;
|
||||
|
||||
/**
|
||||
* Mock class for AbstractSchemaManager.
|
||||
*/
|
||||
class SchemaManagerMock extends \Doctrine\DBAL\Schema\AbstractSchemaManager
|
||||
{
|
||||
/**
|
||||
* @param \Doctrine\DBAL\Connection $conn
|
||||
*/
|
||||
public function __construct(\Doctrine\DBAL\Connection $conn)
|
||||
{
|
||||
parent::__construct($conn);
|
||||
}
|
||||
|
||||
protected function _getPortableTableColumnDefinition($tableColumn) {}
|
||||
}
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function _getPortableTableColumnDefinition($tableColumn)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
@ -4,10 +4,19 @@ namespace Doctrine\Tests\Mocks;
|
||||
|
||||
use Doctrine\ORM\EntityManager;
|
||||
|
||||
/**
|
||||
* Mock class for SequenceGenerator.
|
||||
*/
|
||||
class SequenceMock extends \Doctrine\ORM\Id\SequenceGenerator
|
||||
{
|
||||
/**
|
||||
* @var int
|
||||
*/
|
||||
private $_sequenceNumber = 0;
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function generate(EntityManager $em, $entity)
|
||||
{
|
||||
return $this->_sequenceNumber++;
|
||||
@ -39,14 +48,19 @@ class SequenceMock extends \Doctrine\ORM\Id\SequenceGenerator
|
||||
|
||||
/* Mock API */
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function reset()
|
||||
{
|
||||
$this->_sequenceNumber = 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function autoinc()
|
||||
{
|
||||
$this->_sequenceNumber++;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -9,17 +9,92 @@ namespace Doctrine\Tests\Mocks;
|
||||
*/
|
||||
class StatementMock implements \IteratorAggregate, \Doctrine\DBAL\Driver\Statement
|
||||
{
|
||||
public function bindValue($param, $value, $type = null){}
|
||||
public function bindParam($column, &$variable, $type = null, $length = null){}
|
||||
public function errorCode(){}
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function bindValue($param, $value, $type = null)
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function bindParam($column, &$variable, $type = null, $length = null)
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function errorCode()
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function errorInfo(){}
|
||||
public function execute($params = null){}
|
||||
public function rowCount(){}
|
||||
public function closeCursor(){}
|
||||
public function columnCount(){}
|
||||
public function setFetchMode($fetchStyle, $arg2 = null, $arg3 = null){}
|
||||
public function fetch($fetchStyle = null){}
|
||||
public function fetchAll($fetchStyle = null){}
|
||||
public function fetchColumn($columnIndex = 0){}
|
||||
public function getIterator(){}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function execute($params = null)
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function rowCount()
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function closeCursor()
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function columnCount()
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function setFetchMode($fetchStyle, $arg2 = null, $arg3 = null)
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function fetch($fetchStyle = null)
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function fetchAll($fetchStyle = null)
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function fetchColumn($columnIndex = 0)
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getIterator()
|
||||
{
|
||||
}
|
||||
}
|
||||
|
@ -25,6 +25,7 @@ use Doctrine\Common\Cli\AbstractNamespace;
|
||||
|
||||
/**
|
||||
* TaskMock used for testing the CLI interface.
|
||||
*
|
||||
* @author Nils Adermann <naderman@naderman.de>
|
||||
*/
|
||||
class TaskMock extends \Doctrine\Common\Cli\Tasks\AbstractTask
|
||||
@ -33,17 +34,20 @@ class TaskMock extends \Doctrine\Common\Cli\Tasks\AbstractTask
|
||||
* Since instances of this class can be created elsewhere all instances
|
||||
* register themselves in this array for later inspection.
|
||||
*
|
||||
* @var array(TaskMock)
|
||||
* @var array (TaskMock)
|
||||
*/
|
||||
static public $instances = array();
|
||||
|
||||
/**
|
||||
* @var int
|
||||
*/
|
||||
private $runCounter = 0;
|
||||
|
||||
/**
|
||||
* Constructor of Task Mock Object.
|
||||
* Makes sure the object can be inspected later.
|
||||
*
|
||||
* @param AbstractNamespace CLI Namespace, passed to parent constructor
|
||||
* @param AbstractNamespace $namespace CLI Namespace, passed to parent constructor.
|
||||
*/
|
||||
function __construct(AbstractNamespace $namespace)
|
||||
{
|
||||
@ -66,6 +70,8 @@ class TaskMock extends \Doctrine\Common\Cli\Tasks\AbstractTask
|
||||
|
||||
/**
|
||||
* Method invoked by CLI to run task.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function run()
|
||||
{
|
||||
@ -73,7 +79,9 @@ class TaskMock extends \Doctrine\Common\Cli\Tasks\AbstractTask
|
||||
}
|
||||
|
||||
/**
|
||||
* Method supposed to generate the CLI Task Documentation
|
||||
* Method supposed to generate the CLI Task Documentation.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function buildDocumentation()
|
||||
{
|
||||
|
@ -2,13 +2,23 @@
|
||||
|
||||
namespace Doctrine\Tests\Mocks;
|
||||
|
||||
/**
|
||||
* Mock class for UnitOfWork.
|
||||
*/
|
||||
class UnitOfWorkMock extends \Doctrine\ORM\UnitOfWork
|
||||
{
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
private $_mockDataChangeSets = array();
|
||||
|
||||
/**
|
||||
* @var array|null
|
||||
*/
|
||||
private $_persisterMock;
|
||||
|
||||
/**
|
||||
* @override
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getEntityPersister($entityName)
|
||||
{
|
||||
@ -17,8 +27,7 @@ class UnitOfWorkMock extends \Doctrine\ORM\UnitOfWork
|
||||
}
|
||||
|
||||
/**
|
||||
* @param <type> $entity
|
||||
* @override
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getEntityChangeSet($entity)
|
||||
{
|
||||
@ -33,26 +42,43 @@ class UnitOfWorkMock extends \Doctrine\ORM\UnitOfWork
|
||||
* Sets a (mock) persister for an entity class that will be returned when
|
||||
* getEntityPersister() is invoked for that class.
|
||||
*
|
||||
* @param <type> $entityName
|
||||
* @param <type> $persister
|
||||
* @param string $entityName
|
||||
* @param \Doctrine\ORM\Persisters\BasicEntityPersister $persister
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function setEntityPersister($entityName, $persister)
|
||||
{
|
||||
$this->_persisterMock[$entityName] = $persister;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param object $entity
|
||||
* @param array $mockChangeSet
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function setDataChangeSet($entity, array $mockChangeSet)
|
||||
{
|
||||
$this->_mockDataChangeSets[spl_object_hash($entity)] = $mockChangeSet;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param object $entity
|
||||
* @param mixed $state
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function setEntityState($entity, $state)
|
||||
{
|
||||
$this->_entityStates[spl_object_hash($entity)] = $state;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function setOriginalEntityData($entity, array $originalData)
|
||||
{
|
||||
$this->_originalEntityData[spl_object_hash($entity)] = $originalData;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user