Skip to content

Commit

Permalink
Merge pull request #3 from eXsio/doctrinegh-10880-reproduction-2-16-0
Browse files Browse the repository at this point in the history
GH10880 reproduction on Doctrine 2.16.0 - proof that it doesn't work anymore
  • Loading branch information
mpdude authored Aug 5, 2023
2 parents c58623c + 7ea8474 commit 0acb138
Showing 1 changed file with 56 additions and 12 deletions.
68 changes: 56 additions & 12 deletions tests/Doctrine/Tests/ORM/Functional/Ticket/GH10880Test.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

namespace Doctrine\Tests\ORM\Functional\Ticket;

use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
use Doctrine\Tests\OrmFunctionalTestCase;

Expand All @@ -14,6 +15,7 @@ protected function setUp(): void
parent::setUp();

$this->setUpEntitySchema([
GH10880BaseProcess::class,
GH10880Process::class,
GH10880ProcessOwner::class,
GH10880ProcessStage::class,
Expand Down Expand Up @@ -42,18 +44,18 @@ public function testProcessShouldBeUpdated(): void
$this->_em->flush();
$this->_em->clear();

$ownerLoaded = $this->_em->find(GH10880ProcessOwner::class, $owner->id);
$ownerLoaded = $this->_em->getRepository(GH10880ProcessOwner::class)->find($owner->id);
$processLoaded = $ownerLoaded->process;

$stageBLoaded = $this->_em->find(GH10880ProcessStage::class, $stageB->id);
$stageBLoaded = $this->_em->getRepository(GH10880ProcessStage::class)->find($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']);
self::assertSame('UPDATE processes SET current_stage = ? WHERE id = ?', $queryLog->queries[0]['sql']);
}
}

Expand All @@ -72,17 +74,44 @@ class GH10880ProcessOwner
public $id = null;

/**
* @ORM\ManyToOne(targetEntity="GH10880Process")
* @ORM\ManyToOne(targetEntity="GH10880Process", cascade={"persist"}, fetch="EAGER")
* @ORM\JoinColumns({
* @ORM\JoinColumn(name="process_id", referencedColumnName="id", onDelete="SET NULL")
* })
*
* @var GH10880Process
*/
public $process;

}

/**
* @ORM\Entity
*/
class GH10880Process
class GH10880Process extends GH10880BaseProcess
{
/**
* @ORM\OneToOne(targetEntity="GH10880ProcessOwner")
* @ORM\JoinColumns({
* @ORM\JoinColumn(name="parent_object_id", referencedColumnName="id", onDelete="CASCADE")
* })
*
* @var GH10880ProcessOwner
*/
public $owner;

}

/**
* @ORM\Entity()
* @ORM\InheritanceType("SINGLE_TABLE")
* @ORM\DiscriminatorColumn(name="process_parent", type="string")
* @ORM\Table(name="processes")
* @ORM\DiscriminatorMap({
* "process" = "GH10880Process"
* })
*/
class GH10880BaseProcess
{
/**
* @ORM\Id
Expand All @@ -94,18 +123,30 @@ class GH10880Process
public $id = null;

/**
* @ORM\OneToOne(targetEntity="GH10880ProcessOwner")
* @ORM\OneToOne(targetEntity="GH10880ProcessStage", fetch="EAGER")
* @ORM\JoinColumns({
* @ORM\JoinColumn(name="current_stage", referencedColumnName="id", onDelete="SET NULL")
* })
*
* @var GH10880ProcessOwner
* @var GH10880ProcessStage
*/
public $owner;
public $currentStage;

/**
* @ORM\OneToOne(targetEntity="GH10880ProcessStage")
* @ORM\OneToMany(targetEntity="GH10880ProcessStage", mappedBy="process", cascade={"all"}, orphanRemoval=true, fetch="EAGER")
* @ORM\JoinColumns({
* @ORM\JoinColumn(name="id", referencedColumnName="process_id", onDelete="CASCADE")
* })
*
* @var GH10880ProcessStage
* @var Collection
*/
public $currentStage;
public $stages;

/**
*
* @ORM\Column(name="parent_object_id", type="string", length=255, nullable=true)
*/
public $parentObject;
}

/**
Expand All @@ -123,7 +164,10 @@ class GH10880ProcessStage
public $id = null;

/**
* @ORM\ManyToOne(targetEntity="GH10880Process")
* @ORM\ManyToOne(targetEntity="GH10880Process", inversedBy="stages")
* @ORM\JoinColumns({
* @ORM\JoinColumn(name="process_id", referencedColumnName="id", onDelete="CASCADE")
* })
*
* @var GH10880Process
*/
Expand Down

0 comments on commit 0acb138

Please sign in to comment.