Adding failing test to demonstrate DDC-2432
Loading proxies with invalid identifiers will currently mark them as initialized regardless of the failure
This commit is contained in:
parent
762f43c3dc
commit
07c207081e
@ -2,6 +2,7 @@
|
||||
|
||||
namespace Doctrine\Tests\ORM\Proxy;
|
||||
|
||||
use Doctrine\ORM\EntityNotFoundException;
|
||||
use Doctrine\ORM\Mapping\ClassMetadata;
|
||||
use Doctrine\ORM\Proxy\ProxyFactory;
|
||||
use Doctrine\Common\Proxy\ProxyGenerator;
|
||||
@ -80,6 +81,60 @@ class ProxyFactoryTest extends \Doctrine\Tests\OrmTestCase
|
||||
|
||||
$this->assertEquals(0, $num, "No proxies generated.");
|
||||
}
|
||||
|
||||
/**
|
||||
* @group DDC-2432
|
||||
*/
|
||||
public function testFailedProxyLoadingDoesNotMarkTheProxyAsInitialized()
|
||||
{
|
||||
$persister = $this->getMock('Doctrine\ORM\Persisters\BasicEntityPersister', array('load'), array(), '', false);
|
||||
$this->uowMock->setEntityPersister('Doctrine\Tests\Models\ECommerce\ECommerceFeature', $persister);
|
||||
|
||||
/* @var $proxy \Doctrine\Common\Proxy\Proxy */
|
||||
$proxy = $this->proxyFactory->getProxy('Doctrine\Tests\Models\ECommerce\ECommerceFeature', array('id' => 42));
|
||||
|
||||
$persister
|
||||
->expects($this->atLeastOnce())
|
||||
->method('load')
|
||||
->will($this->returnValue(null));
|
||||
|
||||
try {
|
||||
$proxy->getDescription();
|
||||
$this->fail('An exception was expected to be raised');
|
||||
} catch (EntityNotFoundException $exception) {
|
||||
}
|
||||
|
||||
$this->assertFalse($proxy->__isInitialized());
|
||||
$this->assertInstanceOf('Closure', $proxy->__getInitializer(), 'The initializer wasn\'t removed');
|
||||
$this->assertInstanceOf('Closure', $proxy->__getCloner(), 'The cloner wasn\'t removed');
|
||||
}
|
||||
|
||||
/**
|
||||
* @group DDC-2432
|
||||
*/
|
||||
public function testFailedProxyCloningDoesNotMarkTheProxyAsInitialized()
|
||||
{
|
||||
$persister = $this->getMock('Doctrine\ORM\Persisters\BasicEntityPersister', array('load'), array(), '', false);
|
||||
$this->uowMock->setEntityPersister('Doctrine\Tests\Models\ECommerce\ECommerceFeature', $persister);
|
||||
|
||||
/* @var $proxy \Doctrine\Common\Proxy\Proxy */
|
||||
$proxy = $this->proxyFactory->getProxy('Doctrine\Tests\Models\ECommerce\ECommerceFeature', array('id' => 42));
|
||||
|
||||
$persister
|
||||
->expects($this->atLeastOnce())
|
||||
->method('load')
|
||||
->will($this->returnValue(null));
|
||||
|
||||
try {
|
||||
$cloned = clone $proxy;
|
||||
$this->fail('An exception was expected to be raised');
|
||||
} catch (EntityNotFoundException $exception) {
|
||||
}
|
||||
|
||||
$this->assertFalse($proxy->__isInitialized());
|
||||
$this->assertInstanceOf('Closure', $proxy->__getInitializer(), 'The initializer wasn\'t removed');
|
||||
$this->assertInstanceOf('Closure', $proxy->__getCloner(), 'The cloner wasn\'t removed');
|
||||
}
|
||||
}
|
||||
|
||||
abstract class AbstractClass
|
||||
|
Loading…
x
Reference in New Issue
Block a user