| 1 |  |  | <?php | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3 |  |  | declare(strict_types=1); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5 |  |  | namespace Doctrine\Tests\ORM\Functional\Ticket; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7 |  |  | use Doctrine\ORM\AbstractQuery; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8 |  |  | use Doctrine\ORM\Annotation as ORM; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9 |  |  | use Doctrine\Tests\GetIterableTester; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10 |  |  | use Doctrine\Tests\OrmFunctionalTestCase; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 12 |  |  | final class GH7496WithGetIterableTest extends OrmFunctionalTestCase | 
            
                                                                                                            
                            
            
                                    
            
            
                | 13 |  |  | { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 14 |  |  |     protected function setUp() : void | 
            
                                                                                                            
                            
            
                                    
            
            
                | 15 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 16 |  |  |         parent::setUp(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 17 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 18 |  |  |         $this->setUpEntitySchema( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 19 |  |  |             [ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 20 |  |  |                 GH7496EntityA::class, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 21 |  |  |                 GH7496EntityB::class, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 22 |  |  |                 GH7496EntityAinB::class, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 23 |  |  |             ] | 
            
                                                                                                            
                            
            
                                    
            
            
                | 24 |  |  |         ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 25 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 26 |  |  |         $this->em->persist($a1 = new GH7496EntityA(1, 'A#1')); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 27 |  |  |         $this->em->persist($a2 = new GH7496EntityA(2, 'A#2')); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 28 |  |  |         $this->em->persist($b1 = new GH7496EntityB(1, 'B#1')); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 29 |  |  |         $this->em->persist(new GH7496EntityAinB(1, $a1, $b1)); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 30 |  |  |         $this->em->persist(new GH7496EntityAinB(2, $a2, $b1)); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 31 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 32 |  |  |         $this->em->flush(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 33 |  |  |         $this->em->clear(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 34 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 35 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 36 |  |  |     public function testNonUniqueObjectHydrationDuringIteration() : void | 
            
                                                                                                            
                            
            
                                    
            
            
                | 37 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 38 |  |  |         $q = $this->em->createQuery( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 39 |  |  |             'SELECT b FROM ' . GH7496EntityAinB::class . ' aib JOIN ' . GH7496EntityB::class . ' b WITH aib.eB = b' | 
            
                                                                                                            
                            
            
                                    
            
            
                | 40 |  |  |         ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 41 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 42 |  |  |         $bs = GetIterableTester::iterableToArray( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 43 |  |  |             $q->getIterable(null, AbstractQuery::HYDRATE_OBJECT) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 44 |  |  |         ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 45 |  |  |         $this->assertCount(2, $bs); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 46 |  |  |         $this->assertInstanceOf(GH7496EntityB::class, $bs[0]); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 47 |  |  |         $this->assertInstanceOf(GH7496EntityB::class, $bs[1]); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 48 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 49 |  |  | } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 50 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 51 |  |  | /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 52 |  |  |  * @ORM\Entity | 
            
                                                                                                            
                            
            
                                    
            
            
                | 53 |  |  |  */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 54 |  |  | class GH7496EntityA | 
            
                                                                                                            
                            
            
                                    
            
            
                | 55 |  |  | { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 56 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 57 |  |  |      * @ORM\Id | 
            
                                                                                                            
                            
            
                                    
            
            
                | 58 |  |  |      * @ORM\Column(type="integer", name="a_id") | 
            
                                                                                                            
                            
            
                                    
            
            
                | 59 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 60 |  |  |     public $id; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 61 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 62 |  |  |     /** @ORM\Column(type="string") */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 63 |  |  |     public $name; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 64 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 65 |  |  |     public function __construct(int $id, string $name) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 66 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 67 |  |  |         $this->id   = $id; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 68 |  |  |         $this->name = $name; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 69 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 70 |  |  | } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 71 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 72 |  |  | /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 73 |  |  |  * @ORM\Entity | 
            
                                                                                                            
                            
            
                                    
            
            
                | 74 |  |  |  */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 75 |  |  | class GH7496EntityB | 
            
                                                                                                            
                            
            
                                    
            
            
                | 76 |  |  | { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 77 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 78 |  |  |      * @ORM\Id | 
            
                                                                                                            
                            
            
                                    
            
            
                | 79 |  |  |      * @ORM\Column(type="integer", name="b_id") | 
            
                                                                                                            
                            
            
                                    
            
            
                | 80 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 81 |  |  |     public $id; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 82 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 83 |  |  |     /** @ORM\Column(type="string") */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 84 |  |  |     public $name; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 85 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 86 |  |  |     public function __construct(int $id, $name) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 87 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 88 |  |  |         $this->id   = $id; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 89 |  |  |         $this->name = $name; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 90 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 91 |  |  | } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 92 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 93 |  |  | /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 94 |  |  |  * @ORM\Entity | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 95 |  |  |  */ | 
            
                                                                        
                            
            
                                    
            
            
                | 96 |  |  | class GH7496EntityAinB | 
            
                                                                        
                            
            
                                    
            
            
                | 97 |  |  | { | 
            
                                                                        
                            
            
                                    
            
            
                | 98 |  |  |     /** | 
            
                                                                        
                            
            
                                    
            
            
                | 99 |  |  |      * @ORM\Id | 
            
                                                                        
                            
            
                                    
            
            
                | 100 |  |  |      * @ORM\Column(type="integer") | 
            
                                                                        
                            
            
                                    
            
            
                | 101 |  |  |      */ | 
            
                                                                        
                            
            
                                    
            
            
                | 102 |  |  |     public $id; | 
            
                                                                        
                            
            
                                    
            
            
                | 103 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 104 |  |  |     /** | 
            
                                                                        
                            
            
                                    
            
            
                | 105 |  |  |      * @ORM\ManyToOne(targetEntity=GH7496EntityA::class) | 
            
                                                                        
                            
            
                                    
            
            
                | 106 |  |  |      * @ORM\JoinColumn(name="a_id", referencedColumnName="a_id", nullable=false) | 
            
                                                                        
                            
            
                                    
            
            
                | 107 |  |  |      */ | 
            
                                                                        
                            
            
                                    
            
            
                | 108 |  |  |     public $eA; | 
            
                                                                        
                            
            
                                    
            
            
                | 109 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 110 |  |  |     /** | 
            
                                                                        
                            
            
                                    
            
            
                | 111 |  |  |      * @ORM\ManyToOne(targetEntity=GH7496EntityB::class) | 
            
                                                                        
                            
            
                                    
            
            
                | 112 |  |  |      * @ORM\JoinColumn(name="b_id", referencedColumnName="b_id", nullable=false) | 
            
                                                                        
                            
            
                                    
            
            
                | 113 |  |  |      */ | 
            
                                                                        
                            
            
                                    
            
            
                | 114 |  |  |     public $eB; | 
            
                                                                        
                            
            
                                    
            
            
                | 115 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 116 |  |  |     public function __construct(int $id, $a, $b) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 117 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 118 |  |  |         $this->id = $id; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 119 |  |  |         $this->eA = $a; | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 120 |  |  |         $this->eB = $b; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 121 |  |  |     } | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 122 |  |  | } | 
            
                                                        
            
                                    
            
            
                | 123 |  |  |  |