-
Notifications
You must be signed in to change notification settings - Fork 2.5k
/
GH10889Test.php
107 lines (93 loc) · 1.96 KB
/
GH10889Test.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
<?php
declare(strict_types=1);
namespace Doctrine\Tests\ORM\Functional\Ticket;
use Doctrine\ORM\Mapping as ORM;
use Doctrine\Tests\OrmFunctionalTestCase;
/**
* @see https://github.com/doctrine/orm/issues/10889
*
* @group GH10889
*/
class GH10889Test extends OrmFunctionalTestCase
{
protected function setUp(): void
{
parent::setUp();
$this->createSchemaForModels(
GH10889User::class,
GH10889Finger::class,
GH10889Hand::class
);
}
public function testIssue(): void
{
$user = new GH10889User();
$hand = new GH10889Hand($user, null);
$this->_em->persist($user);
$this->_em->persist($hand);
$this->_em->flush();
$this->_em->clear();
/** @var list<GH10889Hand> $hands */
$hands = $this->_em
->getRepository(GH10889Hand::class)
->createQueryBuilder('hand')
->leftJoin('hand.thumb', 'thumb')->addSelect('thumb')
->getQuery()
->getResult();
$this->assertArrayHasKey(0, $hands);
$this->assertEquals(1, $hands[0]->user->id);
$this->assertNull($hands[0]->thumb);
}
}
/**
* @ORM\Entity
*/
class GH10889User
{
/**
* @ORM\Id
* @ORM\Column(type="integer")
* @ORM\GeneratedValue
*
* @var int
*/
public $id;
}
/**
* @ORM\Entity
*/
class GH10889Finger
{
/**
* @ORM\Id
* @ORM\Column(type="integer")
* @ORM\GeneratedValue
*
* @var int
*/
public $id;
}
/**
* @ORM\Entity
*/
class GH10889Hand
{
/**
* @ORM\Id
* @ORM\OneToOne(targetEntity="GH10889User")
*
* @var GH10889User
*/
public $user;
/**
* @ORM\ManyToOne(targetEntity="GH10889Finger")
*
* @var GH10889Finger|null
*/
public $thumb;
public function __construct(GH10889User $user, ?GH10889Finger $thumb)
{
$this->user = $user;
$this->thumb = $thumb;
}
}