Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit c58623c

Browse files
committed
(Try to) add a reproducer for #10880
1 parent a616914 commit c58623c

1 file changed

Lines changed: 131 additions & 0 deletions

File tree

Lines changed: 131 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,131 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace Doctrine\Tests\ORM\Functional\Ticket;
6+
7+
use Doctrine\ORM\Mapping as ORM;
8+
use Doctrine\Tests\OrmFunctionalTestCase;
9+
10+
class GH10880Test extends OrmFunctionalTestCase
11+
{
12+
protected function setUp(): void
13+
{
14+
parent::setUp();
15+
16+
$this->setUpEntitySchema([
17+
GH10880Process::class,
18+
GH10880ProcessOwner::class,
19+
GH10880ProcessStage::class,
20+
]);
21+
}
22+
23+
public function testProcessShouldBeUpdated(): void
24+
{
25+
$process = new GH10880Process();
26+
27+
$stageA = new GH10880ProcessStage();
28+
$stageA->process = $process;
29+
$process->currentStage = $stageA;
30+
31+
$stageB = new GH10880ProcessStage();
32+
$stageB->process = $process;
33+
34+
$owner = new GH10880ProcessOwner();
35+
$owner->process = $process;
36+
$process->owner = $owner;
37+
38+
$this->_em->persist($process);
39+
$this->_em->persist($stageA);
40+
$this->_em->persist($stageB);
41+
$this->_em->persist($owner);
42+
$this->_em->flush();
43+
$this->_em->clear();
44+
45+
$ownerLoaded = $this->_em->find(GH10880ProcessOwner::class, $owner->id);
46+
$processLoaded = $ownerLoaded->process;
47+
48+
$stageBLoaded = $this->_em->find(GH10880ProcessStage::class, $stageB->id);
49+
$processLoaded->currentStage = $stageBLoaded;
50+
51+
$queryLog = $this->getQueryLog();
52+
$queryLog->reset()->enable();
53+
$this->_em->flush();
54+
55+
self::assertCount(1, $queryLog->queries);
56+
self::assertSame('UPDATE GH10880Process SET currentStage_id = ? WHERE id = ?', $queryLog->queries[0]['sql']);
57+
}
58+
}
59+
60+
/**
61+
* @ORM\Entity
62+
*/
63+
class GH10880ProcessOwner
64+
{
65+
/**
66+
* @ORM\Id
67+
* @ORM\GeneratedValue
68+
* @ORM\Column(type="integer")
69+
*
70+
* @var int
71+
*/
72+
public $id = null;
73+
74+
/**
75+
* @ORM\ManyToOne(targetEntity="GH10880Process")
76+
*
77+
* @var GH10880Process
78+
*/
79+
public $process;
80+
}
81+
82+
/**
83+
* @ORM\Entity
84+
*/
85+
class GH10880Process
86+
{
87+
/**
88+
* @ORM\Id
89+
* @ORM\GeneratedValue
90+
* @ORM\Column(type="integer")
91+
*
92+
* @var int
93+
*/
94+
public $id = null;
95+
96+
/**
97+
* @ORM\OneToOne(targetEntity="GH10880ProcessOwner")
98+
*
99+
* @var GH10880ProcessOwner
100+
*/
101+
public $owner;
102+
103+
/**
104+
* @ORM\OneToOne(targetEntity="GH10880ProcessStage")
105+
*
106+
* @var GH10880ProcessStage
107+
*/
108+
public $currentStage;
109+
}
110+
111+
/**
112+
* @ORM\Entity
113+
*/
114+
class GH10880ProcessStage
115+
{
116+
/**
117+
* @ORM\Id
118+
* @ORM\GeneratedValue
119+
* @ORM\Column(type="integer")
120+
*
121+
* @var int
122+
*/
123+
public $id = null;
124+
125+
/**
126+
* @ORM\ManyToOne(targetEntity="GH10880Process")
127+
*
128+
* @var GH10880Process
129+
*/
130+
public $process;
131+
}

0 commit comments

Comments
 (0)