2008-12-18 17:08:11 +03:00
|
|
|
<?php
|
2009-01-04 19:15:32 +03:00
|
|
|
|
2009-01-22 22:38:10 +03:00
|
|
|
namespace Doctrine\Tests\Mocks;
|
2008-12-18 17:08:11 +03:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Description of Doctrine_UnitOfWorkMock
|
|
|
|
*
|
|
|
|
* @author robo
|
|
|
|
*/
|
2009-01-22 22:38:10 +03:00
|
|
|
class UnitOfWorkMock extends \Doctrine\ORM\UnitOfWork {
|
2008-12-18 17:08:11 +03:00
|
|
|
private $_mockDataChangeSets = array();
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @param <type> $entity
|
|
|
|
* @override
|
|
|
|
*/
|
2009-01-09 19:25:06 +03:00
|
|
|
public function getEntityChangeSet($entity) {
|
2009-01-03 22:50:13 +03:00
|
|
|
$oid = spl_object_hash($entity);
|
2008-12-18 17:08:11 +03:00
|
|
|
return isset($this->_mockDataChangeSets[$oid]) ?
|
2009-01-09 19:25:06 +03:00
|
|
|
$this->_mockDataChangeSets[$oid] : parent::getEntityChangeSet($entity);
|
2008-12-18 17:08:11 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
/* MOCK API */
|
|
|
|
|
|
|
|
public function setDataChangeSet($entity, array $mockChangeSet) {
|
2009-01-03 22:50:13 +03:00
|
|
|
$this->_mockDataChangeSets[spl_object_hash($entity)] = $mockChangeSet;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function setEntityState($entity, $state)
|
|
|
|
{
|
|
|
|
$this->_entityStates[spl_object_hash($entity)] = $state;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function setOriginalEntityData($entity, array $originalData)
|
|
|
|
{
|
|
|
|
$this->_originalEntityData[spl_object_hash($entity)] = $originalData;
|
2008-12-18 17:08:11 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|