-
Notifications
You must be signed in to change notification settings - Fork 2.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
(Try to) add a reproducer for #10880
- Loading branch information
Showing
1 changed file
with
127 additions
and
0 deletions.
There are no files selected for viewing
127 changes: 127 additions & 0 deletions
127
tests/Doctrine/Tests/ORM/Functional/Ticket/GH10880Test.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,127 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Doctrine\Tests\ORM\Functional\Ticket; | ||
|
||
use Doctrine\ORM\Mapping as ORM; | ||
use Doctrine\Tests\OrmFunctionalTestCase; | ||
|
||
class GH10880Test extends OrmFunctionalTestCase | ||
{ | ||
protected function setUp(): void | ||
{ | ||
parent::setUp(); | ||
|
||
$this->setUpEntitySchema([ | ||
GH10880Process::class, | ||
GH10880ProcessOwner::class, | ||
GH10880ProcessStage::class, | ||
]); | ||
} | ||
|
||
public function testProcessShouldBeUpdated(): void | ||
{ | ||
$process = new GH10880Process(); | ||
|
||
$stageA = new GH10880ProcessStage(); | ||
$stageA->process = $process; | ||
$process->currentStage = $stageA; | ||
|
||
$stageB = new GH10880ProcessStage(); | ||
$stageB->process = $process; | ||
|
||
$owner = new GH10880ProcessOwner(); | ||
$owner->process = $process; | ||
$process->owner = $owner; | ||
|
||
$this->_em->persist($process); | ||
$this->_em->persist($stageA); | ||
$this->_em->persist($stageB); | ||
$this->_em->persist($owner); | ||
$this->_em->flush(); | ||
$this->_em->clear(); | ||
|
||
$ownerLoaded = $this->_em->find(GH10880ProcessOwner::class, $owner->id); | ||
$processLoaded = $ownerLoaded->process; | ||
|
||
$stageBLoaded = $this->_em->find(GH10880ProcessStage::class, $stageB->id); | ||
$processLoaded->currentStage = $stageBLoaded; | ||
|
||
$queryLog = $this->getQueryLog(); | ||
$queryLog->reset()->enable(); | ||
$this->_em->flush(); | ||
|
||
self::assertCount(1, $queryLog->queries); | ||
self::assertSame('UPDATE GH10880Process SET currentStage_id = ? WHERE id = ?', $queryLog->queries[0]['sql']); | ||
} | ||
} | ||
|
||
/** | ||
* @ORM\Entity | ||
*/ | ||
class GH10880ProcessOwner | ||
{ | ||
/** | ||
* @ORM\Id | ||
* @ORM\GeneratedValue | ||
* @ORM\Column(type="integer") | ||
* | ||
* @var int | ||
*/ | ||
public $id = null; | ||
|
||
/** | ||
* @ORM\ManyToOne(targetEntity="GH10880Process") | ||
* | ||
* @var GH10880Process | ||
*/ | ||
public $process; | ||
} | ||
|
||
/** | ||
* @ORM\Entity | ||
*/ | ||
class GH10880Process | ||
{ | ||
/** | ||
* @ORM\Id | ||
* @ORM\GeneratedValue | ||
* @ORM\Column(type="integer") | ||
* | ||
* @var int | ||
*/ | ||
public $id = null; | ||
|
||
/** | ||
* @ORM\OneToOne(targetEntity="GH10880ProcessOwner") | ||
*/ | ||
public $owner; | ||
Check failure on line 99 in tests/Doctrine/Tests/ORM/Functional/Ticket/GH10880Test.php GitHub Actions / coding-standards / Coding Standards (8.2)
|
||
|
||
/** | ||
* @ORM\OneToOne(targetEntity="GH10880ProcessStage") | ||
*/ | ||
public $currentStage; | ||
Check failure on line 104 in tests/Doctrine/Tests/ORM/Functional/Ticket/GH10880Test.php GitHub Actions / coding-standards / Coding Standards (8.2)
|
||
} | ||
|
||
/** | ||
* @ORM\Entity | ||
*/ | ||
class GH10880ProcessStage | ||
{ | ||
/** | ||
* @ORM\Id | ||
* @ORM\GeneratedValue | ||
* @ORM\Column(type="integer") | ||
* | ||
* @var int | ||
*/ | ||
public $id = null; | ||
|
||
/** | ||
* @ORM\ManyToOne(targetEntity="GH10880Process") | ||
* | ||
* @var GH10880Process | ||
*/ | ||
public $process; | ||
} |