From 3df119f4feee3c93f758ddce1e01850f1dc6c58a Mon Sep 17 00:00:00 2001 From: Marco Pivetta Date: Fri, 16 Jan 2015 21:23:47 +0100 Subject: [PATCH] #1172 - when merging an initialized proxy, the managed proxy must be initialized before merging --- .../MergeUninitializedProxyTest.php | 33 ++++++++++++++----- 1 file changed, 25 insertions(+), 8 deletions(-) diff --git a/tests/Doctrine/Tests/ORM/Functional/MergeUninitializedProxyTest.php b/tests/Doctrine/Tests/ORM/Functional/MergeUninitializedProxyTest.php index f5661c98e..cf3b4c713 100644 --- a/tests/Doctrine/Tests/ORM/Functional/MergeUninitializedProxyTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/MergeUninitializedProxyTest.php @@ -62,6 +62,27 @@ class MergeUninitializedProxyTest extends \Doctrine\Tests\OrmFunctionalTestCase $this->assertFalse($managed->__isInitialized()); } + public function testMergeInitializedProxy() + { + $file = new MUPFile(); + + $this->_em->persist($file); + $this->_em->flush(); + $this->_em->clear(); + + $initialized = $this->_em->getReference(MUPFile::CLASSNAME, $file->fileId); + + $initialized->__load(); + + $this->_em->clear(); + + $managed = $this->_em->getReference(MUPFile::CLASSNAME, $file->fileId); + + $this->assertSame($managed, $this->_em->merge($initialized)); + + $this->assertTrue($managed->__isInitialized()); + } + public function testMergeUnserializedIntoEntity() { $file = new MUPFile; @@ -212,18 +233,14 @@ class MUPPicture } -/** - * @Entity - */ +/** @Entity */ class MUPFile { const CLASSNAME = __CLASS__; - /** - * @Column(name="file_id", type="integer") - * @Id - * @GeneratedValue(strategy="AUTO") - */ + /** @Column(name="file_id", type="integer") @Id @GeneratedValue(strategy="AUTO") */ public $fileId; + /** @Column(type="string", nullable=true) */ + private $contents; }