|
1
|
|
|
<?php |
|
2
|
|
|
namespace Doctrine\Tests\ORM\Functional\Ticket; |
|
3
|
|
|
|
|
4
|
|
|
use Doctrine\DBAL\Platforms\AbstractPlatform; |
|
5
|
|
|
use Doctrine\DBAL\Types\StringType; |
|
6
|
|
|
use Doctrine\DBAL\Types\Type; |
|
7
|
|
|
use Doctrine\ORM\AbstractQuery; |
|
8
|
|
|
use Doctrine\Tests\OrmFunctionalTestCase; |
|
9
|
|
|
|
|
10
|
|
|
final class GH5562Test extends OrmFunctionalTestCase |
|
11
|
|
|
{ |
|
12
|
|
|
protected function setUp() |
|
13
|
|
|
{ |
|
14
|
|
|
$this->enableSecondLevelCache(); |
|
15
|
|
|
|
|
16
|
|
|
parent::setUp(); |
|
17
|
|
|
|
|
18
|
|
|
$this->_schemaTool->createSchema( |
|
19
|
|
|
[ |
|
20
|
|
|
$this->_em->getClassMetadata(GH5562User::class), |
|
21
|
|
|
$this->_em->getClassMetadata(GH5562Manager::class), |
|
22
|
|
|
$this->_em->getClassMetadata(GH5562Merchant::class), |
|
23
|
|
|
] |
|
24
|
|
|
); |
|
25
|
|
|
} |
|
26
|
|
|
|
|
27
|
|
|
/** |
|
28
|
|
|
* @group 5562 |
|
29
|
|
|
*/ |
|
30
|
|
|
public function testCacheShouldBeUpdatedWhenAssociationChanges() |
|
31
|
|
|
{ |
|
32
|
|
|
$manager = new GH5562Manager(); |
|
33
|
|
|
$merchant = new GH5562Merchant(); |
|
34
|
|
|
|
|
35
|
|
|
$manager->username = 'username'; |
|
36
|
|
|
$manager->merchant = $merchant; |
|
37
|
|
|
$merchant->manager = $manager; |
|
38
|
|
|
|
|
39
|
|
|
$merchant->name = 'Merchant'; |
|
40
|
|
|
|
|
41
|
|
|
$this->_em->persist($merchant); |
|
42
|
|
|
$this->_em->persist($manager); |
|
43
|
|
|
$this->_em->flush(); |
|
44
|
|
|
$this->_em->clear(); |
|
45
|
|
|
|
|
46
|
|
|
$merchant = $this->_em->find(GH5562Merchant::class, $merchant->id); |
|
47
|
|
|
|
|
48
|
|
|
$merchant->name = mt_rand(); |
|
49
|
|
|
$merchant->manager->username = 'usernameUPDATE'; |
|
50
|
|
|
|
|
51
|
|
|
$this->_em->flush(); |
|
52
|
|
|
$this->_em->clear(); |
|
53
|
|
|
|
|
54
|
|
|
$merchant = $this->_em->find(GH5562Merchant::class, $merchant->id); |
|
55
|
|
|
|
|
56
|
|
|
self::assertEquals('usernameUPDATE', $merchant->manager->username); |
|
57
|
|
|
} |
|
58
|
|
|
} |
|
59
|
|
|
|
|
60
|
|
|
/** |
|
61
|
|
|
* @Entity |
|
62
|
|
|
* @Cache(usage="NONSTRICT_READ_WRITE") |
|
63
|
|
|
*/ |
|
64
|
|
|
class GH5562Merchant |
|
65
|
|
|
{ |
|
66
|
|
|
/** |
|
67
|
|
|
* @var integer |
|
68
|
|
|
* |
|
69
|
|
|
* @Id |
|
70
|
|
|
* @Column(name="id", type="integer") |
|
71
|
|
|
* @GeneratedValue(strategy="IDENTITY") |
|
72
|
|
|
*/ |
|
73
|
|
|
public $id; |
|
74
|
|
|
|
|
75
|
|
|
/** |
|
76
|
|
|
* @var GH5562Manager |
|
77
|
|
|
* |
|
78
|
|
|
* @OneToOne(targetEntity=GH5562Manager::class, mappedBy="merchant") |
|
79
|
|
|
* @Cache(usage="NONSTRICT_READ_WRITE") |
|
80
|
|
|
*/ |
|
81
|
|
|
public $manager; |
|
82
|
|
|
|
|
83
|
|
|
/** |
|
84
|
|
|
* @var string |
|
85
|
|
|
* |
|
86
|
|
|
* @Column(name="name", type="string", length=255, nullable=false) |
|
87
|
|
|
*/ |
|
88
|
|
|
public $name; |
|
89
|
|
|
} |
|
90
|
|
|
|
|
91
|
|
|
/** |
|
92
|
|
|
* @Entity |
|
93
|
|
|
* @InheritanceType("SINGLE_TABLE") |
|
94
|
|
|
* @DiscriminatorMap({"MANAGER" = GH5562Manager::class}) |
|
95
|
|
|
*/ |
|
96
|
|
|
abstract class GH5562User |
|
97
|
|
|
{ |
|
98
|
|
|
/** |
|
99
|
|
|
* @var integer |
|
100
|
|
|
* |
|
101
|
|
|
* @Id |
|
102
|
|
|
* @Column(name="id", type="integer") |
|
103
|
|
|
* @GeneratedValue(strategy="IDENTITY") |
|
104
|
|
|
*/ |
|
105
|
|
|
public $id; |
|
106
|
|
|
} |
|
107
|
|
|
|
|
108
|
|
|
/** |
|
109
|
|
|
* @Entity |
|
110
|
|
|
* @Cache(usage="NONSTRICT_READ_WRITE") |
|
111
|
|
|
*/ |
|
112
|
|
|
class GH5562Manager extends GH5562User |
|
113
|
|
|
{ |
|
114
|
|
|
|
|
115
|
|
|
/** |
|
116
|
|
|
* @var string |
|
117
|
|
|
* |
|
118
|
|
|
* @Column |
|
119
|
|
|
*/ |
|
120
|
|
|
public $username; |
|
121
|
|
|
|
|
122
|
|
|
/** |
|
123
|
|
|
* @var GH5562Merchant |
|
124
|
|
|
* |
|
125
|
|
|
* @OneToOne(targetEntity=GH5562Merchant::class, inversedBy="manager") |
|
126
|
|
|
*/ |
|
127
|
|
|
public $merchant; |
|
128
|
|
|
} |
|
129
|
|
|
|