forked from doctrine/orm
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
103 additions
and
0 deletions.
There are no files selected for viewing
103 changes: 103 additions & 0 deletions
103
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,103 @@ | ||
<?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([ | ||
GH10880BaseProcess::class, | ||
GH10880Process::class, | ||
GH10880ProcessOwner::class, | ||
]); | ||
} | ||
|
||
public function testProcessShouldBeUpdated(): void | ||
{ | ||
$process = new GH10880Process(); | ||
$process->description = 'first value'; | ||
|
||
$owner = new GH10880ProcessOwner(); | ||
$owner->process = $process; | ||
|
||
$this->_em->persist($process); | ||
$this->_em->persist($owner); | ||
$this->_em->flush(); | ||
$this->_em->clear(); | ||
|
||
$ownerLoaded = $this->_em->getRepository(GH10880ProcessOwner::class)->find($owner->id); | ||
$ownerLoaded->process->description = 'other description'; | ||
|
||
$queryLog = $this->getQueryLog(); | ||
$queryLog->reset()->enable(); | ||
$this->_em->flush(); | ||
|
||
self::assertCount(1, $queryLog->queries); | ||
self::assertSame('UPDATE GH10880BaseProcess SET description = ? WHERE id = ?', $queryLog->queries[0]['sql']); | ||
} | ||
} | ||
|
||
/** | ||
* @ORM\Entity | ||
*/ | ||
class GH10880ProcessOwner | ||
{ | ||
/** | ||
* @ORM\Id | ||
* @ORM\GeneratedValue | ||
* @ORM\Column(type="integer") | ||
* | ||
* @var int | ||
*/ | ||
public $id; | ||
|
||
/** | ||
* fetch=EAGER is important to reach the part of \Doctrine\ORM\UnitOfWork::createEntity() | ||
* that is important for this regression test | ||
* | ||
* @ORM\ManyToOne(targetEntity="GH10880Process", fetch="EAGER") | ||
* | ||
* @var GH10880Process | ||
*/ | ||
public $process; | ||
} | ||
|
||
/** | ||
* @ORM\Entity() | ||
* @ORM\InheritanceType("SINGLE_TABLE") | ||
* @ORM\DiscriminatorColumn(name="type", type="string") | ||
* @ORM\DiscriminatorMap({"process" = "GH10880Process"}) | ||
*/ | ||
abstract class GH10880BaseProcess | ||
{ | ||
/** | ||
* @ORM\Id | ||
* @ORM\GeneratedValue | ||
* @ORM\Column(type="integer") | ||
* | ||
* @var int | ||
*/ | ||
public $id; | ||
|
||
/** | ||
* @ORM\Column(type="text") | ||
* | ||
* @var string | ||
*/ | ||
public $description; | ||
} | ||
|
||
/** | ||
* @ORM\Entity | ||
*/ | ||
class GH10880Process extends GH10880BaseProcess | ||
{ | ||
} |