Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Unit tests: cleanup of outdated / unused / commented out code #579

Merged
merged 1 commit into from

3 participants

Benjamin Morel doctrinebot Benjamin Eberlei
Benjamin Morel

Many methods in unit tests were unused, in particular in mocks, where methods overriding in the past were not overriding anything anymore.

Some commented out code was referring to features that seem to have been removed years ago, so I removed it as well.

HydratorMockStatement::bindParam() was adding extra parameters that its parent did not define, and that were never used, so I removed them as well.

doctrinebot
Collaborator

Hello,

thank you for positing this Pull Request. I have automatically opened an issue on our Jira Bug Tracker for you with the details of this Pull-Request. See the Link:

http://doctrine-project.org/jira/browse/DDC-2294

Benjamin Eberlei beberlei merged commit dba63c5 into from
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
This page is out of date. Refresh to see the latest.
14 tests/Doctrine/Tests/Mocks/DriverMock.php
View
@@ -26,20 +26,6 @@ public function connect(array $params, $username = null, $password = null, array
}
/**
- * Constructs the Sqlite PDO DSN.
- *
- * @param array $params
- *
- * @return string The DSN.
- *
- * @override
- */
- protected function _constructPdoDsn(array $params)
- {
- return "";
- }
-
- /**
* {@inheritdoc}
*/
public function getDatabasePlatform()
22 tests/Doctrine/Tests/Mocks/EntityManagerMock.php
View
@@ -39,11 +39,6 @@ class EntityManagerMock extends \Doctrine\ORM\EntityManager
private $_proxyFactoryMock;
/**
- * @var array
- */
- private $_idGenerators = array();
-
- /**
* {@inheritdoc}
*/
public function getUnitOfWork()
@@ -103,21 +98,4 @@ public static function create($conn, \Doctrine\ORM\Configuration $config = null,
return new EntityManagerMock($conn, $config, $eventManager);
}
-/*
- public function setIdGenerator($className, $generator)
- {
- $this->_idGenerators[$className] = $generator;
- }
-*/
- /** @override */
-/* public function getIdGenerator($className)
- {
-
- if (isset($this->_idGenerators[$className])) {
- return $this->_idGenerators[$className];
- }
-
- return parent::getIdGenerator($className);
- }
- */
}
19 tests/Doctrine/Tests/Mocks/EntityPersisterMock.php
View
@@ -46,25 +46,6 @@ class EntityPersisterMock extends \Doctrine\ORM\Persisters\BasicEntityPersister
* @param object $entity
*
* @return mixed
- *
- * @override
- */
- public function insert($entity)
- {
- $this->inserts[] = $entity;
- if ( ! is_null($this->mockIdGeneratorType) && $this->mockIdGeneratorType == \Doctrine\ORM\Mapping\ClassMetadata::GENERATOR_TYPE_IDENTITY
- || $this->class->isIdGeneratorIdentity()) {
- $id = $this->identityColumnValueCounter++;
- $this->postInsertIds[$id] = $entity;
- return $id;
- }
- return null;
- }
-
- /**
- * @param object $entity
- *
- * @return mixed
*/
public function addInsert($entity)
{
17 tests/Doctrine/Tests/Mocks/HydratorMockStatement.php
View
@@ -69,21 +69,6 @@ public function closeCursor()
}
/**
- * @param array $resultSet
- *
- * @return void
- */
- public function setResultSet(array $resultSet)
- {
- reset($resultSet);
- $this->_resultSet = $resultSet;
- }
-
- public function bindColumn($column, &$param, $type = null)
- {
- }
-
- /**
* {@inheritdoc}
*/
public function bindValue($param, $value, $type = null)
@@ -93,7 +78,7 @@ 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)
{
}
16 tests/Doctrine/Tests/Mocks/IdentityIdGeneratorMock.php
View
@@ -1,16 +0,0 @@
-<?php
-
-namespace Doctrine\Tests\Mocks;
-
-/**
- * Mock class for IdentityGenerator.
- */
-class IdentityIdGeneratorMock extends \Doctrine\ORM\Id\IdentityGenerator
-{
- private $_mockPostInsertId;
-
- public function setMockPostInsertId($id)
- {
- $this->_mockPostInsertId = $id;
- }
-}
32 tests/Doctrine/Tests/Mocks/SequenceMock.php
View
@@ -22,30 +22,6 @@ public function generate(EntityManager $em, $entity)
return $this->_sequenceNumber++;
}
- /**
- * @override
- */
- public function nextId($seqName, $ondemand = true)
- {
- return $this->_sequenceNumber++;
- }
-
- /**
- * @override
- */
- public function lastInsertId($table = null, $field = null)
- {
- return $this->_sequenceNumber - 1;
- }
-
- /**
- * @override
- */
- public function currId($seqName)
- {
- return $this->_sequenceNumber;
- }
-
/* Mock API */
/**
@@ -55,12 +31,4 @@ public function reset()
{
$this->_sequenceNumber = 0;
}
-
- /**
- * @return void
- */
- public function autoinc()
- {
- $this->_sequenceNumber++;
- }
}
22 tests/Doctrine/Tests/Mocks/UnitOfWorkMock.php
View
@@ -53,28 +53,6 @@ public function setEntityPersister($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)
7 tests/Doctrine/Tests/ORM/UnitOfWorkTest.php
View
@@ -7,7 +7,6 @@
use Doctrine\Tests\Mocks\EntityManagerMock;
use Doctrine\Tests\Mocks\UnitOfWorkMock;
use Doctrine\Tests\Mocks\EntityPersisterMock;
-use Doctrine\Tests\Mocks\IdentityIdGeneratorMock;
use Doctrine\Tests\Models\Forum\ForumUser;
use Doctrine\Tests\Models\Forum\ForumAvatar;
@@ -54,8 +53,6 @@ public function testSavingSingleEntityWithIdentityColumnForcesInsert()
// Setup fake persister and id generator for identity generation
$userPersister = new EntityPersisterMock($this->_emMock, $this->_emMock->getClassMetadata("Doctrine\Tests\Models\Forum\ForumUser"));
$this->_unitOfWork->setEntityPersister('Doctrine\Tests\Models\Forum\ForumUser', $userPersister);
- //$idGeneratorMock = new IdentityIdGeneratorMock($this->_emMock);
- //$this->_emMock->setIdGenerator('Doctrine\Tests\Models\Forum\ForumUser', $idGeneratorMock);
$userPersister->setMockIdGeneratorType(\Doctrine\ORM\Mapping\ClassMetadata::GENERATOR_TYPE_IDENTITY);
// Test
@@ -96,14 +93,10 @@ public function testCascadedIdentityColumnInsert()
//ForumUser
$userPersister = new EntityPersisterMock($this->_emMock, $this->_emMock->getClassMetadata("Doctrine\Tests\Models\Forum\ForumUser"));
$this->_unitOfWork->setEntityPersister('Doctrine\Tests\Models\Forum\ForumUser', $userPersister);
- //$userIdGeneratorMock = new IdentityIdGeneratorMock($this->_emMock);
- //$this->_emMock->setIdGenerator('Doctrine\Tests\Models\Forum\ForumUser', $userIdGeneratorMock);
$userPersister->setMockIdGeneratorType(\Doctrine\ORM\Mapping\ClassMetadata::GENERATOR_TYPE_IDENTITY);
// ForumAvatar
$avatarPersister = new EntityPersisterMock($this->_emMock, $this->_emMock->getClassMetadata("Doctrine\Tests\Models\Forum\ForumAvatar"));
$this->_unitOfWork->setEntityPersister('Doctrine\Tests\Models\Forum\ForumAvatar', $avatarPersister);
- //$avatarIdGeneratorMock = new IdentityIdGeneratorMock($this->_emMock);
- //$this->_emMock->setIdGenerator('Doctrine\Tests\Models\Forum\ForumAvatar', $avatarIdGeneratorMock);
$avatarPersister->setMockIdGeneratorType(\Doctrine\ORM\Mapping\ClassMetadata::GENERATOR_TYPE_IDENTITY);
// Test
Something went wrong with that request. Please try again.