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

Fixed documentation for Doctrine\Tests\Mocks

This commit is contained in:
Benjamin Morel 2012-12-14 18:55:28 +00:00
parent 76f2ba50eb
commit c405f6d3f6
16 changed files with 588 additions and 99 deletions

View file

@ -2,13 +2,18 @@
namespace Doctrine\Tests\Mocks; namespace Doctrine\Tests\Mocks;
/**
* Mock class for ClassMetadata.
*/
class ClassMetadataMock extends \Doctrine\ORM\Mapping\ClassMetadata class ClassMetadataMock extends \Doctrine\ORM\Mapping\ClassMetadata
{ {
/* Mock API */ /* Mock API */
/**
* {@inheritdoc}
*/
public function setIdGeneratorType($type) public function setIdGeneratorType($type)
{ {
$this->_generatorType = $type; $this->_generatorType = $type;
} }
}
}

View file

@ -2,14 +2,42 @@
namespace Doctrine\Tests\Mocks; namespace Doctrine\Tests\Mocks;
/**
* Mock class for Connection.
*/
class ConnectionMock extends \Doctrine\DBAL\Connection class ConnectionMock extends \Doctrine\DBAL\Connection
{ {
/**
* @var mixed
*/
private $_fetchOneResult; private $_fetchOneResult;
/**
* @var DatabasePlatformMock
*/
private $_platformMock; private $_platformMock;
/**
* @var int
*/
private $_lastInsertId = 0; private $_lastInsertId = 0;
/**
* @var array
*/
private $_inserts = array(); private $_inserts = array();
/**
* @var array
*/
private $_executeUpdates = 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) public function __construct(array $params, $driver, $config = null, $eventManager = null)
{ {
$this->_platformMock = new DatabasePlatformMock(); $this->_platformMock = new DatabasePlatformMock();
@ -21,7 +49,7 @@ class ConnectionMock extends \Doctrine\DBAL\Connection
} }
/** /**
* @override * {@inheritdoc}
*/ */
public function getDatabasePlatform() public function getDatabasePlatform()
{ {
@ -29,7 +57,7 @@ class ConnectionMock extends \Doctrine\DBAL\Connection
} }
/** /**
* @override * {@inheritdoc}
*/ */
public function insert($tableName, array $data, array $types = array()) 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()) 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) 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) 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) public function quote($input, $type = null)
{ {
@ -73,34 +101,58 @@ class ConnectionMock extends \Doctrine\DBAL\Connection
/* Mock API */ /* Mock API */
/**
* @param mixed $fetchOneResult
*
* @return void
*/
public function setFetchOneResult($fetchOneResult) public function setFetchOneResult($fetchOneResult)
{ {
$this->_fetchOneResult = $fetchOneResult; $this->_fetchOneResult = $fetchOneResult;
} }
/**
* @param \Doctrine\DBAL\Platforms\AbstractPlatform $platform
*
* @return void
*/
public function setDatabasePlatform($platform) public function setDatabasePlatform($platform)
{ {
$this->_platformMock = $platform; $this->_platformMock = $platform;
} }
/**
* @param int $id
*
* @return void
*/
public function setLastInsertId($id) public function setLastInsertId($id)
{ {
$this->_lastInsertId = $id; $this->_lastInsertId = $id;
} }
/**
* @return array
*/
public function getInserts() public function getInserts()
{ {
return $this->_inserts; return $this->_inserts;
} }
/**
* @return array
*/
public function getExecuteUpdates() public function getExecuteUpdates()
{ {
return $this->_executeUpdates; return $this->_executeUpdates;
} }
/**
* @return void
*/
public function reset() public function reset()
{ {
$this->_inserts = array(); $this->_inserts = array();
$this->_lastInsertId = 0; $this->_lastInsertId = 0;
} }
} }

View file

@ -2,24 +2,42 @@
namespace Doctrine\Tests\Mocks; namespace Doctrine\Tests\Mocks;
/**
* Mock class for DatabasePlatform.
*/
class DatabasePlatformMock extends \Doctrine\DBAL\Platforms\AbstractPlatform class DatabasePlatformMock extends \Doctrine\DBAL\Platforms\AbstractPlatform
{ {
/**
* @var string
*/
private $_sequenceNextValSql = ""; private $_sequenceNextValSql = "";
/**
* @var bool
*/
private $_prefersIdentityColumns = true; private $_prefersIdentityColumns = true;
/**
* @var bool
*/
private $_prefersSequences = false; 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() public function prefersIdentityColumns()
{ {
@ -27,71 +45,122 @@ class DatabasePlatformMock extends \Doctrine\DBAL\Platforms\AbstractPlatform
} }
/** /**
* @override * {@inheritdoc}
*/ */
public function prefersSequences() public function prefersSequences()
{ {
return $this->_prefersSequences; return $this->_prefersSequences;
} }
/** @override */ /**
* {@inheritdoc}
*/
public function getSequenceNextValSQL($sequenceName) public function getSequenceNextValSQL($sequenceName)
{ {
return $this->_sequenceNextValSql; 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 */ /* MOCK API */
/**
* @param bool $bool
*
* @return void
*/
public function setPrefersIdentityColumns($bool) public function setPrefersIdentityColumns($bool)
{ {
$this->_prefersIdentityColumns = $bool; $this->_prefersIdentityColumns = $bool;
} }
/**
* @param bool $bool
*
* @return void
*/
public function setPrefersSequences($bool) public function setPrefersSequences($bool)
{ {
$this->_prefersSequences = $bool; $this->_prefersSequences = $bool;
} }
/**
* @param string $sql
*
* @return void
*/
public function setSequenceNextValSql($sql) public function setSequenceNextValSql($sql)
{ {
$this->_sequenceNextValSql = $sql; $this->_sequenceNextValSql = $sql;
} }
/**
* {@inheritdoc}
*/
public function getName() public function getName()
{ {
return 'mock'; return 'mock';
} }
/**
* {@inheritdoc}
*/
protected function initializeDoctrineTypeMappings() protected function initializeDoctrineTypeMappings()
{ {
} }
/** /**
* Gets the SQL Snippet used to declare a BLOB column type. * {@inheritdoc}
*/ */
public function getBlobTypeDeclarationSQL(array $field) public function getBlobTypeDeclarationSQL(array $field)
{ {
throw DBALException::notSupported(__METHOD__); throw DBALException::notSupported(__METHOD__);
} }
} }

View file

@ -2,16 +2,79 @@
namespace Doctrine\Tests\Mocks; namespace Doctrine\Tests\Mocks;
/**
* Mock class for DriverConnection.
*/
class DriverConnectionMock implements \Doctrine\DBAL\Driver\Connection class DriverConnectionMock implements \Doctrine\DBAL\Driver\Connection
{ {
public function prepare($prepareString) {} /**
public function query() { return new StatementMock; } * {@inheritdoc}
public function quote($input, $type=\PDO::PARAM_STR) {} */
public function exec($statement) {} public function prepare($prepareString)
public function lastInsertId($name = null) {} {
public function beginTransaction() {} }
public function commit() {}
public function rollBack() {} /**
public function errorCode() {} * {@inheritdoc}
public function errorInfo() {} */
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()
{
}
} }

View file

@ -2,13 +2,24 @@
namespace Doctrine\Tests\Mocks; namespace Doctrine\Tests\Mocks;
/**
* Mock class for Driver.
*/
class DriverMock implements \Doctrine\DBAL\Driver class DriverMock implements \Doctrine\DBAL\Driver
{ {
/**
* @var \Doctrine\DBAL\Platforms\AbstractPlatform|null
*/
private $_platformMock; private $_platformMock;
/**
* @var \Doctrine\DBAL\Schema\AbstractSchemaManager|null
*/
private $_schemaManagerMock; private $_schemaManagerMock;
/**
* {@inheritdoc}
*/
public function connect(array $params, $username = null, $password = null, array $driverOptions = array()) public function connect(array $params, $username = null, $password = null, array $driverOptions = array())
{ {
return new DriverConnectionMock(); return new DriverConnectionMock();
@ -17,7 +28,10 @@ class DriverMock implements \Doctrine\DBAL\Driver
/** /**
* Constructs the Sqlite PDO DSN. * Constructs the Sqlite PDO DSN.
* *
* @return string The DSN. * @param array $params
*
* @return string The DSN.
*
* @override * @override
*/ */
protected function _constructPdoDsn(array $params) protected function _constructPdoDsn(array $params)
@ -26,7 +40,7 @@ class DriverMock implements \Doctrine\DBAL\Driver
} }
/** /**
* @override * {@inheritdoc}
*/ */
public function getDatabasePlatform() public function getDatabasePlatform()
{ {
@ -37,11 +51,11 @@ class DriverMock implements \Doctrine\DBAL\Driver
} }
/** /**
* @override * {@inheritdoc}
*/ */
public function getSchemaManager(\Doctrine\DBAL\Connection $conn) public function getSchemaManager(\Doctrine\DBAL\Connection $conn)
{ {
if($this->_schemaManagerMock == null) { if ($this->_schemaManagerMock == null) {
return new SchemaManagerMock($conn); return new SchemaManagerMock($conn);
} else { } else {
return $this->_schemaManagerMock; return $this->_schemaManagerMock;
@ -50,23 +64,39 @@ class DriverMock implements \Doctrine\DBAL\Driver
/* MOCK API */ /* MOCK API */
/**
* @param \Doctrine\DBAL\Platforms\AbstractPlatform $platform
*
* @return void
*/
public function setDatabasePlatform(\Doctrine\DBAL\Platforms\AbstractPlatform $platform) public function setDatabasePlatform(\Doctrine\DBAL\Platforms\AbstractPlatform $platform)
{ {
$this->_platformMock = $platform; $this->_platformMock = $platform;
} }
/**
* @param \Doctrine\DBAL\Schema\AbstractSchemaManager $sm
*
* @return void
*/
public function setSchemaManager(\Doctrine\DBAL\Schema\AbstractSchemaManager $sm) public function setSchemaManager(\Doctrine\DBAL\Schema\AbstractSchemaManager $sm)
{ {
$this->_schemaManagerMock = $sm; $this->_schemaManagerMock = $sm;
} }
/**
* {@inheritdoc}
*/
public function getName() public function getName()
{ {
return 'mock'; return 'mock';
} }
/**
* {@inheritdoc}
*/
public function getDatabase(\Doctrine\DBAL\Connection $conn) public function getDatabase(\Doctrine\DBAL\Connection $conn)
{ {
return; return;
} }
} }

View file

@ -28,12 +28,23 @@ use Doctrine\ORM\Proxy\ProxyFactory;
*/ */
class EntityManagerMock extends \Doctrine\ORM\EntityManager class EntityManagerMock extends \Doctrine\ORM\EntityManager
{ {
/**
* @var \Doctrine\ORM\UnitOfWork|null
*/
private $_uowMock; private $_uowMock;
/**
* @var \Doctrine\ORM\Proxy\ProxyFactory|null
*/
private $_proxyFactoryMock; private $_proxyFactoryMock;
/**
* @var array
*/
private $_idGenerators = array(); private $_idGenerators = array();
/** /**
* @override * {@inheritdoc}
*/ */
public function getUnitOfWork() 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. * 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) public function setUnitOfWork($uow)
{ {
$this->_uowMock = $uow; $this->_uowMock = $uow;
} }
/**
* @param \Doctrine\ORM\Proxy\ProxyFactory $proxyFactory
*
* @return void
*/
public function setProxyFactory($proxyFactory) public function setProxyFactory($proxyFactory)
{ {
$this->_proxyFactoryMock = $proxyFactory; $this->_proxyFactoryMock = $proxyFactory;
} }
/**
* @return \Doctrine\ORM\Proxy\ProxyFactory
*/
public function getProxyFactory() public function getProxyFactory()
{ {
return isset($this->_proxyFactoryMock) ? $this->_proxyFactoryMock : parent::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. * Mock factory method to create an EntityManager.
* *
* @param unknown_type $conn * {@inheritdoc}
* @param unknown_type $name
* @param Doctrine_Configuration $config
* @param Doctrine_EventManager $eventManager
* @return Doctrine\ORM\EntityManager
*/ */
public static function create($conn, \Doctrine\ORM\Configuration $config = null, public static function create($conn, \Doctrine\ORM\Configuration $config = null,
\Doctrine\Common\EventManager $eventManager = null) \Doctrine\Common\EventManager $eventManager = null)

View file

@ -7,17 +7,46 @@ namespace Doctrine\Tests\Mocks;
*/ */
class EntityPersisterMock extends \Doctrine\ORM\Persisters\BasicEntityPersister class EntityPersisterMock extends \Doctrine\ORM\Persisters\BasicEntityPersister
{ {
/**
* @var array
*/
private $inserts = array(); private $inserts = array();
/**
* @var array
*/
private $updates = array(); private $updates = array();
/**
* @var array
*/
private $deletes = array(); private $deletes = array();
/**
* @var int
*/
private $identityColumnValueCounter = 0; private $identityColumnValueCounter = 0;
/**
* @var int|null
*/
private $mockIdGeneratorType; private $mockIdGeneratorType;
/**
* @var array
*/
private $postInsertIds = array(); private $postInsertIds = array();
/**
* @var bool
*/
private $existsCalled = false; private $existsCalled = false;
/** /**
* @param <type> $entity * @param object $entity
* @return <type> *
* @return mixed
*
* @override * @override
*/ */
public function insert($entity) public function insert($entity)
@ -32,6 +61,11 @@ class EntityPersisterMock extends \Doctrine\ORM\Persisters\BasicEntityPersister
return null; return null;
} }
/**
* @param object $entity
*
* @return mixed
*/
public function addInsert($entity) public function addInsert($entity)
{ {
$this->inserts[] = $entity; $this->inserts[] = $entity;
@ -44,46 +78,75 @@ class EntityPersisterMock extends \Doctrine\ORM\Persisters\BasicEntityPersister
return null; return null;
} }
/**
* @return array
*/
public function executeInserts() public function executeInserts()
{ {
return $this->postInsertIds; return $this->postInsertIds;
} }
/**
* @param int $genType
*
* @return void
*/
public function setMockIdGeneratorType($genType) public function setMockIdGeneratorType($genType)
{ {
$this->mockIdGeneratorType = $genType; $this->mockIdGeneratorType = $genType;
} }
/**
* {@inheritdoc}
*/
public function update($entity) public function update($entity)
{ {
$this->updates[] = $entity; $this->updates[] = $entity;
} }
/**
* {@inheritdoc}
*/
public function exists($entity, array $extraConditions = array()) public function exists($entity, array $extraConditions = array())
{ {
$this->existsCalled = true; $this->existsCalled = true;
} }
/**
* {@inheritdoc}
*/
public function delete($entity) public function delete($entity)
{ {
$this->deletes[] = $entity; $this->deletes[] = $entity;
} }
/**
* @return array
*/
public function getInserts() public function getInserts()
{ {
return $this->inserts; return $this->inserts;
} }
/**
* @return array
*/
public function getUpdates() public function getUpdates()
{ {
return $this->updates; return $this->updates;
} }
/**
* @return array
*/
public function getDeletes() public function getDeletes()
{ {
return $this->deletes; return $this->deletes;
} }
/**
* @return void
*/
public function reset() public function reset()
{ {
$this->existsCalled = false; $this->existsCalled = false;
@ -93,8 +156,11 @@ class EntityPersisterMock extends \Doctrine\ORM\Persisters\BasicEntityPersister
$this->deletes = array(); $this->deletes = array();
} }
/**
* @return bool
*/
public function isExistsCalled() public function isExistsCalled()
{ {
return $this->existsCalled; return $this->existsCalled;
} }
} }

View file

@ -10,12 +10,15 @@ namespace Doctrine\Tests\Mocks;
*/ */
class HydratorMockStatement implements \IteratorAggregate, \Doctrine\DBAL\Driver\Statement class HydratorMockStatement implements \IteratorAggregate, \Doctrine\DBAL\Driver\Statement
{ {
/**
* @var array
*/
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.
* *
* @param array $resultSet The faked SQL result set. * @param array $resultSet The faked SQL result set.
*/ */
public function __construct(array $resultSet) public function __construct(array $resultSet)
{ {
@ -25,6 +28,10 @@ class HydratorMockStatement implements \IteratorAggregate, \Doctrine\DBAL\Driver
/** /**
* Fetches all rows from the result set. * Fetches all rows from the result set.
* *
* @param int|null $fetchStyle
* @param int|null $columnIndex
* @param array|null $ctorArgs
*
* @return array * @return array
*/ */
public function fetchAll($fetchStyle = null, $columnIndex = null, array $ctorArgs = null) public function fetchAll($fetchStyle = null, $columnIndex = null, array $ctorArgs = null)
@ -32,6 +39,9 @@ class HydratorMockStatement implements \IteratorAggregate, \Doctrine\DBAL\Driver
return $this->_resultSet; return $this->_resultSet;
} }
/**
* {@inheritdoc}
*/
public function fetchColumn($columnNumber = 0) public function fetchColumn($columnNumber = 0)
{ {
$row = current($this->_resultSet); $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) 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. * {@inheritdoc}
*
* @return boolean
*/ */
public function closeCursor() public function closeCursor()
{ {
return true; return true;
} }
/**
* @param array $resultSet
*
* @return void
*/
public function setResultSet(array $resultSet) public function setResultSet(array $resultSet)
{ {
reset($resultSet); reset($resultSet);
@ -71,41 +83,67 @@ class HydratorMockStatement implements \IteratorAggregate, \Doctrine\DBAL\Driver
{ {
} }
/**
* {@inheritdoc}
*/
public function bindValue($param, $value, $type = null) public function bindValue($param, $value, $type = null)
{ {
} }
/**
* {@inheritdoc}
*/
public function bindParam($column, &$variable, $type = null, $length = null, $driverOptions = array()) public function bindParam($column, &$variable, $type = null, $length = null, $driverOptions = array())
{ {
} }
/**
* {@inheritdoc}
*/
public function columnCount() public function columnCount()
{ {
} }
/**
* {@inheritdoc}
*/
public function errorCode() public function errorCode()
{ {
} }
/**
* {@inheritdoc}
*/
public function errorInfo() public function errorInfo()
{ {
} }
/**
* {@inheritdoc}
*/
public function execute($params = array()) public function execute($params = array())
{ {
} }
/**
* {@inheritdoc}
*/
public function rowCount() public function rowCount()
{ {
} }
/**
* {@inheritdoc}
*/
public function getIterator() public function getIterator()
{ {
return $this->_resultSet; return $this->_resultSet;
} }
/**
* {@inheritdoc}
*/
public function setFetchMode($fetchStyle, $arg2 = null, $arg3 = null) public function setFetchMode($fetchStyle, $arg2 = null, $arg3 = null)
{ {
} }
} }

View file

@ -2,11 +2,15 @@
namespace Doctrine\Tests\Mocks; namespace Doctrine\Tests\Mocks;
/**
* Mock class for IdentityGenerator.
*/
class IdentityIdGeneratorMock extends \Doctrine\ORM\Id\IdentityGenerator class IdentityIdGeneratorMock extends \Doctrine\ORM\Id\IdentityGenerator
{ {
private $_mockPostInsertId; private $_mockPostInsertId;
public function setMockPostInsertId($id) { public function setMockPostInsertId($id)
{
$this->_mockPostInsertId = $id; $this->_mockPostInsertId = $id;
} }
} }

View file

@ -2,20 +2,31 @@
namespace Doctrine\Tests\Mocks; namespace Doctrine\Tests\Mocks;
/**
* Mock class for MappingDriver.
*/
class MetadataDriverMock implements \Doctrine\Common\Persistence\Mapping\Driver\MappingDriver class MetadataDriverMock implements \Doctrine\Common\Persistence\Mapping\Driver\MappingDriver
{ {
/**
* {@inheritdoc}
*/
public function loadMetadataForClass($className, \Doctrine\Common\Persistence\Mapping\ClassMetadata $metadata) public function loadMetadataForClass($className, \Doctrine\Common\Persistence\Mapping\ClassMetadata $metadata)
{ {
return;
} }
/**
* {@inheritdoc}
*/
public function isTransient($className) public function isTransient($className)
{ {
return false; return false;
} }
/**
* {@inheritdoc}
*/
public function getAllClassNames() public function getAllClassNames()
{ {
return array(); return array();
} }
} }

View file

@ -2,16 +2,16 @@
namespace Doctrine\Tests\Mocks; namespace Doctrine\Tests\Mocks;
/**
* Mock class for TreeWalker.
*/
class MockTreeWalker extends \Doctrine\ORM\Query\TreeWalkerAdapter class MockTreeWalker extends \Doctrine\ORM\Query\TreeWalkerAdapter
{ {
/** /**
* Gets an executor that can be used to execute the result of this walker. * {@inheritdoc}
*
* @return AbstractExecutor
*/ */
public function getExecutor($AST) public function getExecutor($AST)
{ {
return null; return null;
} }
} }

View file

@ -2,12 +2,23 @@
namespace Doctrine\Tests\Mocks; namespace Doctrine\Tests\Mocks;
/**
* Mock class for AbstractSchemaManager.
*/
class SchemaManagerMock extends \Doctrine\DBAL\Schema\AbstractSchemaManager class SchemaManagerMock extends \Doctrine\DBAL\Schema\AbstractSchemaManager
{ {
/**
* @param \Doctrine\DBAL\Connection $conn
*/
public function __construct(\Doctrine\DBAL\Connection $conn) public function __construct(\Doctrine\DBAL\Connection $conn)
{ {
parent::__construct($conn); parent::__construct($conn);
} }
protected function _getPortableTableColumnDefinition($tableColumn) {} /**
} * {@inheritdoc}
*/
protected function _getPortableTableColumnDefinition($tableColumn)
{
}
}

View file

@ -4,10 +4,19 @@ namespace Doctrine\Tests\Mocks;
use Doctrine\ORM\EntityManager; use Doctrine\ORM\EntityManager;
/**
* Mock class for SequenceGenerator.
*/
class SequenceMock extends \Doctrine\ORM\Id\SequenceGenerator class SequenceMock extends \Doctrine\ORM\Id\SequenceGenerator
{ {
/**
* @var int
*/
private $_sequenceNumber = 0; private $_sequenceNumber = 0;
/**
* {@inheritdoc}
*/
public function generate(EntityManager $em, $entity) public function generate(EntityManager $em, $entity)
{ {
return $this->_sequenceNumber++; return $this->_sequenceNumber++;
@ -39,14 +48,19 @@ class SequenceMock extends \Doctrine\ORM\Id\SequenceGenerator
/* Mock API */ /* Mock API */
/**
* @return void
*/
public function reset() public function reset()
{ {
$this->_sequenceNumber = 0; $this->_sequenceNumber = 0;
} }
/**
* @return void
*/
public function autoinc() public function autoinc()
{ {
$this->_sequenceNumber++; $this->_sequenceNumber++;
} }
} }

View file

@ -9,17 +9,92 @@ namespace Doctrine\Tests\Mocks;
*/ */
class StatementMock implements \IteratorAggregate, \Doctrine\DBAL\Driver\Statement class StatementMock implements \IteratorAggregate, \Doctrine\DBAL\Driver\Statement
{ {
public function bindValue($param, $value, $type = null){} /**
public function bindParam($column, &$variable, $type = null, $length = null){} * {@inheritdoc}
public function errorCode(){} */
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 errorInfo(){}
public function execute($params = null){}
public function rowCount(){} /**
public function closeCursor(){} * {@inheritdoc}
public function columnCount(){} */
public function setFetchMode($fetchStyle, $arg2 = null, $arg3 = null){} public function execute($params = null)
public function fetch($fetchStyle = null){} {
public function fetchAll($fetchStyle = null){} }
public function fetchColumn($columnIndex = 0){}
public function getIterator(){} /**
* {@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()
{
}
} }

View file

@ -25,6 +25,7 @@ use Doctrine\Common\Cli\AbstractNamespace;
/** /**
* TaskMock used for testing the CLI interface. * TaskMock used for testing the CLI interface.
*
* @author Nils Adermann <naderman@naderman.de> * @author Nils Adermann <naderman@naderman.de>
*/ */
class TaskMock extends \Doctrine\Common\Cli\Tasks\AbstractTask 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 * Since instances of this class can be created elsewhere all instances
* register themselves in this array for later inspection. * register themselves in this array for later inspection.
* *
* @var array(TaskMock) * @var array (TaskMock)
*/ */
static public $instances = array(); static public $instances = array();
/**
* @var int
*/
private $runCounter = 0; private $runCounter = 0;
/** /**
* Constructor of Task Mock Object. * Constructor of Task Mock Object.
* Makes sure the object can be inspected later. * 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) function __construct(AbstractNamespace $namespace)
{ {
@ -66,6 +70,8 @@ class TaskMock extends \Doctrine\Common\Cli\Tasks\AbstractTask
/** /**
* Method invoked by CLI to run task. * Method invoked by CLI to run task.
*
* @return void
*/ */
public function run() 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() public function buildDocumentation()
{ {

View file

@ -2,13 +2,23 @@
namespace Doctrine\Tests\Mocks; namespace Doctrine\Tests\Mocks;
/**
* Mock class for UnitOfWork.
*/
class UnitOfWorkMock extends \Doctrine\ORM\UnitOfWork class UnitOfWorkMock extends \Doctrine\ORM\UnitOfWork
{ {
/**
* @var array
*/
private $_mockDataChangeSets = array(); private $_mockDataChangeSets = array();
/**
* @var array|null
*/
private $_persisterMock; private $_persisterMock;
/** /**
* @override * {@inheritdoc}
*/ */
public function getEntityPersister($entityName) public function getEntityPersister($entityName)
{ {
@ -17,8 +27,7 @@ class UnitOfWorkMock extends \Doctrine\ORM\UnitOfWork
} }
/** /**
* @param <type> $entity * {@inheritdoc}
* @override
*/ */
public function getEntityChangeSet($entity) 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 * Sets a (mock) persister for an entity class that will be returned when
* getEntityPersister() is invoked for that class. * getEntityPersister() is invoked for that class.
* *
* @param <type> $entityName * @param string $entityName
* @param <type> $persister * @param \Doctrine\ORM\Persisters\BasicEntityPersister $persister
*
* @return void
*/ */
public function setEntityPersister($entityName, $persister) public function setEntityPersister($entityName, $persister)
{ {
$this->_persisterMock[$entityName] = $persister; $this->_persisterMock[$entityName] = $persister;
} }
/**
* @param object $entity
* @param array $mockChangeSet
*
* @return void
*/
public function setDataChangeSet($entity, array $mockChangeSet) public function setDataChangeSet($entity, array $mockChangeSet)
{ {
$this->_mockDataChangeSets[spl_object_hash($entity)] = $mockChangeSet; $this->_mockDataChangeSets[spl_object_hash($entity)] = $mockChangeSet;
} }
/**
* @param object $entity
* @param mixed $state
*
* @return void
*/
public function setEntityState($entity, $state) public function setEntityState($entity, $state)
{ {
$this->_entityStates[spl_object_hash($entity)] = $state; $this->_entityStates[spl_object_hash($entity)] = $state;
} }
/**
* {@inheritdoc}
*/
public function setOriginalEntityData($entity, array $originalData) public function setOriginalEntityData($entity, array $originalData)
{ {
$this->_originalEntityData[spl_object_hash($entity)] = $originalData; $this->_originalEntityData[spl_object_hash($entity)] = $originalData;
} }
} }