Fixed tests + added dedicated tests for proxy loading and identifiers
This commit is contained in:
parent
8d1b852aa2
commit
d46352da01
@ -78,9 +78,6 @@ class LifecycleCallbackTest extends \Doctrine\Tests\OrmFunctionalTestCase
|
||||
$reference = $this->_em->getReference('Doctrine\Tests\ORM\Functional\LifecycleCallbackTestEntity', $id);
|
||||
$this->assertFalse($reference->postLoadCallbackInvoked);
|
||||
|
||||
$reference->getId(); // doesn't trigger proxy load
|
||||
$this->assertFalse($reference->postLoadCallbackInvoked);
|
||||
|
||||
$reference->getValue(); // trigger proxy load
|
||||
$this->assertTrue($reference->postLoadCallbackInvoked);
|
||||
}
|
||||
|
@ -147,4 +147,28 @@ class ReferenceProxyTest extends \Doctrine\Tests\OrmFunctionalTestCase
|
||||
|
||||
$this->assertTrue($entity->wakeUp, "Loading the proxy should call __wakeup().");
|
||||
}
|
||||
|
||||
public function testDoNotInitializeProxyOnGettingTheIdentifier()
|
||||
{
|
||||
$id = $this->createProduct();
|
||||
|
||||
/* @var $entity Doctrine\Tests\Models\ECommerce\ECommerceProduct */
|
||||
$entity = $this->_em->getReference('Doctrine\Tests\Models\ECommerce\ECommerceProduct' , $id);
|
||||
|
||||
$this->assertFalse($entity->__isInitialized__, "Pre-Condition: Object is unitialized proxy.");
|
||||
$this->assertEquals($id, $entity->getId());
|
||||
$this->assertFalse($entity->__isInitialized__, "Getting the identifier doesn't initialize the proxy.");
|
||||
}
|
||||
|
||||
public function testInitializeProxyOnGettingSomethingOtherThanTheIdentifier()
|
||||
{
|
||||
$id = $this->createProduct();
|
||||
|
||||
/* @var $entity Doctrine\Tests\Models\ECommerce\ECommerceProduct */
|
||||
$entity = $this->_em->getReference('Doctrine\Tests\Models\ECommerce\ECommerceProduct' , $id);
|
||||
|
||||
$this->assertFalse($entity->__isInitialized__, "Pre-Condition: Object is unitialized proxy.");
|
||||
$this->assertEquals('Doctrine Cookbook', $entity->getName());
|
||||
$this->assertTrue($entity->__isInitialized__, "Getting something other than the identifier initializes the proxy.");
|
||||
}
|
||||
}
|
||||
|
@ -73,12 +73,13 @@ class ProxyClassGeneratorTest extends \Doctrine\Tests\OrmTestCase
|
||||
$persister = $this->_getMockPersister();
|
||||
$this->_uowMock->setEntityPersister('Doctrine\Tests\Models\ECommerce\ECommerceFeature', $persister);
|
||||
$proxy = $this->_proxyFactory->getProxy('Doctrine\Tests\Models\ECommerce\ECommerceFeature', $identifier);
|
||||
|
||||
$persister->expects($this->atLeastOnce())
|
||||
->method('load')
|
||||
->with($this->equalTo($identifier), $this->isInstanceOf($proxyClass))
|
||||
->will($this->returnValue(new \stdClass())); // fake return of entity instance
|
||||
$proxy->getId();
|
||||
$proxy->getDescription();
|
||||
$proxy->getProduct();
|
||||
}
|
||||
|
||||
public function testReferenceProxyRespectsMethodsParametersTypeHinting()
|
||||
|
Loading…
Reference in New Issue
Block a user