Merge pull request #274 from mvrhov/DDC-1625
Proxy not initialized when parent has get<IDENTIFIER> function.
This commit is contained in:
commit
19a4d05035
@ -285,7 +285,7 @@ class ProxyFactory
|
||||
);
|
||||
|
||||
if ($cheapCheck) {
|
||||
$code = file($class->reflClass->getFileName());
|
||||
$code = file($method->getDeclaringClass()->getFileName());
|
||||
$code = trim(implode(" ", array_slice($code, $method->getStartLine() - 1, $method->getEndLine() - $method->getStartLine() + 1)));
|
||||
|
||||
$pattern = sprintf(self::PATTERN_MATCH_ID_METHOD, $method->getName(), $identifier);
|
||||
|
@ -6,6 +6,7 @@ use Doctrine\ORM\Proxy\ProxyFactory;
|
||||
use Doctrine\ORM\Proxy\ProxyClassGenerator;
|
||||
use Doctrine\Tests\Models\ECommerce\ECommerceProduct;
|
||||
use Doctrine\Tests\Models\ECommerce\ECommerceShipping;
|
||||
use Doctrine\Tests\Models\Company\CompanyAuction;
|
||||
|
||||
require_once __DIR__ . '/../../TestInit.php';
|
||||
|
||||
@ -39,6 +40,18 @@ class ReferenceProxyTest extends \Doctrine\Tests\OrmFunctionalTestCase
|
||||
return $product->getId();
|
||||
}
|
||||
|
||||
public function createAuction()
|
||||
{
|
||||
$event = new CompanyAuction();
|
||||
$event->setData('Doctrine Cookbook');
|
||||
$this->_em->persist($event);
|
||||
|
||||
$this->_em->flush();
|
||||
$this->_em->clear();
|
||||
|
||||
return $event->getId();
|
||||
}
|
||||
|
||||
public function testLazyLoadsFieldValuesFromDatabase()
|
||||
{
|
||||
$id = $this->createProduct();
|
||||
@ -161,6 +174,21 @@ class ReferenceProxyTest extends \Doctrine\Tests\OrmFunctionalTestCase
|
||||
$this->assertFalse($entity->__isInitialized__, "Getting the identifier doesn't initialize the proxy.");
|
||||
}
|
||||
|
||||
/**
|
||||
* @group DDC-1625
|
||||
*/
|
||||
public function testDoNotInitializeProxyOnGettingTheIdentifier_DDC_1625()
|
||||
{
|
||||
$id = $this->createAuction();
|
||||
|
||||
/* @var $entity Doctrine\Tests\Models\Company\CompanyAuction */
|
||||
$entity = $this->_em->getReference('Doctrine\Tests\Models\Company\CompanyAuction' , $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 when extending.");
|
||||
}
|
||||
|
||||
public function testDoNotInitializeProxyOnGettingTheIdentifierAndReturnTheRightType()
|
||||
{
|
||||
$product = new ECommerceProduct();
|
||||
|
Loading…
x
Reference in New Issue
Block a user