| 1 |  |  | <?php | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3 |  |  | declare(strict_types=1); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5 |  |  | namespace Doctrine\Tests\ORM\Functional\Ticket; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7 |  |  | use Doctrine\ORM\Annotation as ORM; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8 |  |  | use Doctrine\Tests\OrmFunctionalTestCase; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10 |  |  | class DDC1458Test extends OrmFunctionalTestCase | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11 |  |  | { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 12 |  |  |     public function setUp() : void | 
            
                                                                                                            
                            
            
                                    
            
            
                | 13 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 14 |  |  |         parent::setUp(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 15 |  |  |         $this->schemaTool->createSchema( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 16 |  |  |             [ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 17 |  |  |                 $this->em->getClassMetadata(TestEntity::class), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 18 |  |  |                 $this->em->getClassMetadata(TestAdditionalEntity::class), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 19 |  |  |             ] | 
            
                                                                                                            
                            
            
                                    
            
            
                | 20 |  |  |         ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 21 |  |  |     } | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 22 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 23 |  |  |     public function testIssue() : void | 
            
                                                                        
                            
            
                                    
            
            
                | 24 |  |  |     { | 
            
                                                                        
                            
            
                                    
            
            
                | 25 |  |  |         $testEntity = new TestEntity(); | 
            
                                                                        
                            
            
                                    
            
            
                | 26 |  |  |         $testEntity->setValue(3); | 
            
                                                                        
                            
            
                                    
            
            
                | 27 |  |  |         $testEntity->setAdditional(new TestAdditionalEntity()); | 
            
                                                                        
                            
            
                                    
            
            
                | 28 |  |  |         $this->em->persist($testEntity); | 
            
                                                                        
                            
            
                                    
            
            
                | 29 |  |  |         $this->em->flush(); | 
            
                                                                        
                            
            
                                    
            
            
                | 30 |  |  |         $this->em->clear(); | 
            
                                                                        
                            
            
                                    
            
            
                | 31 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 32 |  |  |         // So here the value is 3 | 
            
                                                                        
                            
            
                                    
            
            
                | 33 |  |  |         self::assertEquals(3, $testEntity->getValue()); | 
            
                                                                        
                            
            
                                    
            
            
                | 34 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 35 |  |  |         $test = $this->em->getRepository(TestEntity::class)->find(1); | 
            
                                                                        
                            
            
                                    
            
            
                | 36 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 37 |  |  |         // New value is set | 
            
                                                                        
                            
            
                                    
            
            
                | 38 |  |  |         $test->setValue(5); | 
            
                                                                        
                            
            
                                    
            
            
                | 39 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 40 |  |  |         // So here the value is 5 | 
            
                                                                        
                            
            
                                    
            
            
                | 41 |  |  |         self::assertEquals(5, $test->getValue()); | 
            
                                                                        
                            
            
                                    
            
            
                | 42 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 43 |  |  |         // Get the additional entity | 
            
                                                                        
                            
            
                                    
            
            
                | 44 |  |  |         $additional = $test->getAdditional(); | 
            
                                                                        
                            
            
                                    
            
            
                | 45 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 46 |  |  |         // Still 5.. | 
            
                                                                        
                            
            
                                    
            
            
                | 47 |  |  |         self::assertEquals(5, $test->getValue()); | 
            
                                                                        
                            
            
                                    
            
            
                | 48 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 49 |  |  |         // Force the proxy to load | 
            
                                                                        
                            
            
                                    
            
            
                | 50 |  |  |         $additional->getBool(); | 
            
                                                                        
                            
            
                                    
            
            
                | 51 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 52 |  |  |         // The value should still be 5 | 
            
                                                                        
                            
            
                                    
            
            
                | 53 |  |  |         self::assertEquals(5, $test->getValue()); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 54 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 55 |  |  | } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 56 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 57 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 58 |  |  | /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 59 |  |  |  * @ORM\Entity | 
            
                                                                                                            
                            
            
                                    
            
            
                | 60 |  |  |  */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 61 |  |  | class TestEntity | 
            
                                                                                                            
                            
            
                                    
            
            
                | 62 |  |  | { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 63 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 64 |  |  |      * @ORM\Id | 
            
                                                                                                            
                            
            
                                    
            
            
                | 65 |  |  |      * @ORM\Column(type="integer") | 
            
                                                                                                            
                            
            
                                    
            
            
                | 66 |  |  |      * @ORM\GeneratedValue(strategy="AUTO") | 
            
                                                                                                            
                            
            
                                    
            
            
                | 67 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 68 |  |  |     protected $id; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 69 |  |  |     /** @ORM\Column(type="integer") */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 70 |  |  |     protected $value; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 71 |  |  |     /** @ORM\OneToOne(targetEntity=TestAdditionalEntity::class, inversedBy="entity", orphanRemoval=true, cascade={"persist", "remove"}) */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 72 |  |  |     protected $additional; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 73 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 74 |  |  |     public function getValue() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 75 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 76 |  |  |         return $this->value; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 77 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 78 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 79 |  |  |     public function setValue($value) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 80 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 81 |  |  |         $this->value = $value; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 82 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 83 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 84 |  |  |     public function getAdditional() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 85 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 86 |  |  |         return $this->additional; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 87 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 88 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 89 |  |  |     public function setAdditional($additional) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 90 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 91 |  |  |         $this->additional = $additional; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 92 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 93 |  |  | } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 94 |  |  | /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 95 |  |  |  * @ORM\Entity | 
            
                                                                                                            
                            
            
                                    
            
            
                | 96 |  |  |  */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 97 |  |  | class TestAdditionalEntity | 
            
                                                                                                            
                            
            
                                    
            
            
                | 98 |  |  | { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 99 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 100 |  |  |      * @ORM\Id | 
            
                                                                                                            
                            
            
                                    
            
            
                | 101 |  |  |      * @ORM\Column(type="integer") | 
            
                                                                                                            
                            
            
                                    
            
            
                | 102 |  |  |      * @ORM\GeneratedValue(strategy="AUTO") | 
            
                                                                                                            
                            
            
                                    
            
            
                | 103 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 104 |  |  |     protected $id; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 105 |  |  |     /** @ORM\OneToOne(targetEntity=TestEntity::class, mappedBy="additional") */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 106 |  |  |     protected $entity; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 107 |  |  |     /** @ORM\Column(type="boolean") */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 108 |  |  |     protected $bool; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 109 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 110 |  |  |     public function __construct() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 111 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 112 |  |  |         $this->bool = false; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 113 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 114 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 115 |  |  |     public function getBool() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 116 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 117 |  |  |         return $this->bool; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 118 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 119 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 120 |  |  |     public function setBool($bool) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 121 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 122 |  |  |         $this->bool = $bool; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 123 |  |  |     } | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 124 |  |  | } | 
            
                                                        
            
                                    
            
            
                | 125 |  |  |  |