| 1 |  |  | <?php | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3 |  |  | declare(strict_types=1); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5 |  |  | namespace Doctrine\Tests\ORM\Functional\Ticket; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7 |  |  | use Doctrine\Tests\OrmFunctionalTestCase; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8 |  |  | use function assert; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10 |  |  | final class GH7735Test extends OrmFunctionalTestCase | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11 |  |  | { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 12 |  |  |     public function setUp() : void | 
            
                                                                                                            
                            
            
                                    
            
            
                | 13 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 14 |  |  |         $this->enableSecondLevelCache(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 15 |  |  |         parent::setUp(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 16 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 17 |  |  |         $this->_schemaTool->createSchema( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 18 |  |  |             [ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 19 |  |  |                 $this->_em->getClassMetadata(GH7735Car::class), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 20 |  |  |                 $this->_em->getClassMetadata(GH7735Power::class), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 21 |  |  |                 $this->_em->getClassMetadata(GH7735Engine::class), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 22 |  |  |             ] | 
            
                                                                                                            
                            
            
                                    
            
            
                | 23 |  |  |         ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 24 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 25 |  |  |         $this->_em->persist(new GH7735Car(1, new GH7735Engine(1, 'turbo', new GH7735Power(1)))); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 26 |  |  |         $this->_em->flush(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 27 |  |  |         $this->_em->clear(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 28 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 29 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 30 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 31 |  |  |      * @test | 
            
                                                                                                            
                            
            
                                    
            
            
                | 32 |  |  |      * @group GH7735 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 33 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 34 |  |  |     public function findByReturnsCachedEntity() : void | 
            
                                                                                                            
                            
            
                                    
            
            
                | 35 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 36 |  |  |         $this->_em->getCache()->evictEntityRegion(GH7735Power::class); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 37 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 38 |  |  |         $car = $this->_em->find(GH7735Car::class, 1); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 39 |  |  |         assert($car instanceof GH7735Car); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 40 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 41 |  |  |         self::assertSame('turbo', $car->getEngine()->getModel()); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 42 |  |  |         self::assertSame(1, $car->getEngine()->getPower()->getId()); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 43 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 44 |  |  | } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 45 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 46 |  |  | /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 47 |  |  |  * @Entity @Cache(usage="READ_ONLY") | 
            
                                                                                                            
                            
            
                                    
            
            
                | 48 |  |  |  */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 49 |  |  | class GH7735Car | 
            
                                                                                                            
                            
            
                                    
            
            
                | 50 |  |  | { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 51 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 52 |  |  |      * @Id | 
            
                                                                                                            
                            
            
                                    
            
            
                | 53 |  |  |      * @Column(type="integer") | 
            
                                                                                                            
                            
            
                                    
            
            
                | 54 |  |  |      * @var int | 
            
                                                                                                            
                            
            
                                    
            
            
                | 55 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 56 |  |  |     private $id; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 57 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 58 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 59 |  |  |      * @ManyToOne(targetEntity=GH7735Engine::class, cascade={"all"}) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 60 |  |  |      * @JoinColumn(nullable=false) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 61 |  |  |      * @Cache("READ_ONLY") | 
            
                                                                                                            
                            
            
                                    
            
            
                | 62 |  |  |      * @var GH7735Engine | 
            
                                                                                                            
                            
            
                                    
            
            
                | 63 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 64 |  |  |     private $engine; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 65 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 66 |  |  |     public function __construct(int $id, GH7735Engine $engine) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 67 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 68 |  |  |         $this->id     = $id; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 69 |  |  |         $this->engine = $engine; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 70 |  |  |     } | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 71 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 72 |  |  |     public function getId() : int | 
            
                                                                        
                            
            
                                    
            
            
                | 73 |  |  |     { | 
            
                                                                        
                            
            
                                    
            
            
                | 74 |  |  |         return $this->id; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 75 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 76 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 77 |  |  |     public function getEngine() : GH7735Engine | 
            
                                                                                                            
                            
            
                                    
            
            
                | 78 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 79 |  |  |         return $this->engine; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 80 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 81 |  |  | } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 82 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 83 |  |  | /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 84 |  |  |  * @Entity | 
            
                                                                                                            
                            
            
                                    
            
            
                | 85 |  |  |  * @Cache(usage="READ_ONLY") | 
            
                                                                                                            
                            
            
                                    
            
            
                | 86 |  |  |  */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 87 |  |  | class GH7735Engine | 
            
                                                                                                            
                            
            
                                    
            
            
                | 88 |  |  | { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 89 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 90 |  |  |      * @Id | 
            
                                                                                                            
                            
            
                                    
            
            
                | 91 |  |  |      * @Column(type="integer") | 
            
                                                                                                            
                            
            
                                    
            
            
                | 92 |  |  |      * @var int | 
            
                                                                                                            
                            
            
                                    
            
            
                | 93 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 94 |  |  |     private $id; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 95 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 96 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 97 |  |  |      * @OneToOne(targetEntity=GH7735Power::class, mappedBy="engine", cascade={"all"}) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 98 |  |  |      * @Cache("READ_ONLY") | 
            
                                                                                                            
                            
            
                                    
            
            
                | 99 |  |  |      * @var GH7735Power | 
            
                                                                                                            
                            
            
                                    
            
            
                | 100 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 101 |  |  |     private $power; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 102 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 103 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 104 |  |  |      * @Column | 
            
                                                                                                            
                            
            
                                    
            
            
                | 105 |  |  |      * @var string | 
            
                                                                                                            
                            
            
                                    
            
            
                | 106 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 107 |  |  |     private $model; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 108 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 109 |  |  |     public function __construct(int $id, string $model, GH7735Power $power) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 110 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 111 |  |  |         $this->id    = $id; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 112 |  |  |         $this->model = $model; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 113 |  |  |         $this->power = $power; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 114 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 115 |  |  |         $power->setEngine($this); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 116 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 117 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 118 |  |  |     public function getId() : int | 
            
                                                                                                            
                            
            
                                    
            
            
                | 119 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 120 |  |  |         return $this->id; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 121 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 122 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 123 |  |  |     public function getPower() : GH7735Power | 
            
                                                                                                            
                            
            
                                    
            
            
                | 124 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 125 |  |  |         return $this->power; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 126 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 127 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 128 |  |  |     public function getModel() : string | 
            
                                                                                                            
                            
            
                                    
            
            
                | 129 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 130 |  |  |         return $this->model; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 131 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 132 |  |  | } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 133 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 134 |  |  | /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 135 |  |  |  * @Entity | 
            
                                                                                                            
                            
            
                                    
            
            
                | 136 |  |  |  * @Cache(usage="READ_ONLY") | 
            
                                                                                                            
                            
            
                                    
            
            
                | 137 |  |  |  */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 138 |  |  | class GH7735Power | 
            
                                                                                                            
                            
            
                                    
            
            
                | 139 |  |  | { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 140 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 141 |  |  |      * @Id | 
            
                                                                                                            
                            
            
                                    
            
            
                | 142 |  |  |      * @Column(type="integer") | 
            
                                                                                                            
                            
            
                                    
            
            
                | 143 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 144 |  |  |     private $id; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 145 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 146 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 147 |  |  |      * @OneToOne(targetEntity=GH7735Engine::class, inversedBy="power") | 
            
                                                                                                            
                            
            
                                    
            
            
                | 148 |  |  |      * @Cache("READ_ONLY") | 
            
                                                                                                            
                            
            
                                    
            
            
                | 149 |  |  |      * @var GH7735Engine | 
            
                                                                                                            
                            
            
                                    
            
            
                | 150 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 151 |  |  |     private $engine; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 152 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 153 |  |  |     public function __construct(int $id) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 154 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 155 |  |  |         $this->id = $id; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 156 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 157 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 158 |  |  |     public function getId() : int | 
            
                                                                                                            
                            
            
                                    
            
            
                | 159 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 160 |  |  |         return $this->id; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 161 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 162 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 163 |  |  |     public function setEngine(GH7735Engine $engine) : void | 
            
                                                                                                            
                            
            
                                    
            
            
                | 164 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 165 |  |  |         $this->engine = $engine; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 166 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 167 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 168 |  |  |     public function getEngine() : GH7735Engine | 
            
                                                                                                            
                            
            
                                    
            
            
                | 169 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 170 |  |  |         return $this->engine; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 171 |  |  |     } | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 172 |  |  | } | 
            
                                                        
            
                                    
            
            
                | 173 |  |  |  |