|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace Doctrine\Tests\ORM\Functional\Ticket; |
|
4
|
|
|
|
|
5
|
|
|
use Doctrine\Common\Collections\ArrayCollection; |
|
6
|
|
|
use Doctrine\Tests\Models\CMS\CmsEmployee; |
|
7
|
|
|
|
|
8
|
|
|
/** |
|
9
|
|
|
* @group 7052 |
|
10
|
|
|
*/ |
|
11
|
|
|
class Issue7052Test extends \Doctrine\Tests\OrmFunctionalTestCase |
|
12
|
|
|
{ |
|
13
|
|
|
public function setUp() |
|
14
|
|
|
{ |
|
15
|
|
|
parent::setUp(); |
|
16
|
|
|
|
|
17
|
|
|
$this->_schemaTool->createSchema(array( |
|
18
|
|
|
$this->_em->getClassMetadata(__NAMESPACE__ . '\\Issue7052Child'), |
|
19
|
|
|
$this->_em->getClassMetadata(__NAMESPACE__ . '\\Issue7052Parent'), |
|
20
|
|
|
)); |
|
21
|
|
|
} |
|
22
|
|
|
|
|
23
|
|
|
public function testIssue() |
|
24
|
|
|
{ |
|
25
|
|
|
$parent = new Issue7052Parent(); |
|
26
|
|
|
$parent->name = "parent test"; |
|
27
|
|
|
|
|
28
|
|
|
$childA = new Issue7052Child(); |
|
29
|
|
|
$childA->parent = $parent; |
|
30
|
|
|
|
|
31
|
|
|
$childB = new Issue7052Child(); |
|
32
|
|
|
$childB->parent = $parent; |
|
33
|
|
|
|
|
34
|
|
|
$this->_em->persist($parent); |
|
35
|
|
|
$this->_em->persist($childA); |
|
36
|
|
|
$this->_em->persist($childB); |
|
37
|
|
|
$this->_em->flush(); |
|
38
|
|
|
$this->_em->clear(); |
|
39
|
|
|
|
|
40
|
|
|
$childAFromDb = $this->_em->find('Doctrine\Tests\ORM\Functional\Ticket\Issue7052Child', $childA->id); |
|
41
|
|
|
|
|
42
|
|
|
$this->_em->clear(); |
|
43
|
|
|
|
|
44
|
|
|
$childBFromDb = $this->_em->find('Doctrine\Tests\ORM\Functional\Ticket\Issue7052Child', $childB->id); |
|
45
|
|
|
|
|
46
|
|
|
$parentFromChildB = $childBFromDb->parent; |
|
|
|
|
|
|
47
|
|
|
|
|
48
|
|
|
self::assertNotSame($childA, $childAFromDb); |
|
49
|
|
|
self::assertNotNull($childAFromDb->parent->name, "Unable to get parent name on second loaded child after EM cleared."); |
|
50
|
|
|
} |
|
51
|
|
|
} |
|
52
|
|
|
|
|
53
|
|
|
/** |
|
54
|
|
|
* @Entity |
|
55
|
|
|
*/ |
|
56
|
|
|
class Issue7052Child |
|
57
|
|
|
{ |
|
58
|
|
|
/** |
|
59
|
|
|
* @Id |
|
60
|
|
|
* @GeneratedValue |
|
61
|
|
|
* @Column(type="integer") |
|
62
|
|
|
*/ |
|
63
|
|
|
public $id; |
|
64
|
|
|
|
|
65
|
|
|
/** |
|
66
|
|
|
* @ManyToOne(targetEntity=Issue7052Parent::class, fetch="LAZY") |
|
67
|
|
|
*/ |
|
68
|
|
|
public $parent; |
|
69
|
|
|
} |
|
70
|
|
|
|
|
71
|
|
|
/** |
|
72
|
|
|
* @Entity |
|
73
|
|
|
*/ |
|
74
|
|
|
class Issue7052Parent |
|
75
|
|
|
{ |
|
76
|
|
|
/** |
|
77
|
|
|
* @Id |
|
78
|
|
|
* @GeneratedValue |
|
79
|
|
|
* @Column(type="integer") |
|
80
|
|
|
*/ |
|
81
|
|
|
public $id; |
|
82
|
|
|
|
|
83
|
|
|
/** |
|
84
|
|
|
* @Column |
|
85
|
|
|
*/ |
|
86
|
|
|
public $name; |
|
87
|
|
|
} |
|
88
|
|
|
|