Skip to content

Commit

Permalink
(Try to) add a reproducer for #10880
Browse files Browse the repository at this point in the history
  • Loading branch information
mpdude committed Aug 5, 2023
1 parent a616914 commit 5cb01e6
Showing 1 changed file with 127 additions and 0 deletions.
127 changes: 127 additions & 0 deletions tests/Doctrine/Tests/ORM/Functional/Ticket/GH10880Test.php
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

View workflow job for this annotation

GitHub Actions / coding-standards / Coding Standards (8.2)

Property \Doctrine\Tests\ORM\Functional\Ticket\GH10880Process::$owner does not have @var annotation for its value.

/**
* @ORM\OneToOne(targetEntity="GH10880ProcessStage")
*/
public $currentStage;

Check failure on line 104 in tests/Doctrine/Tests/ORM/Functional/Ticket/GH10880Test.php

View workflow job for this annotation

GitHub Actions / coding-standards / Coding Standards (8.2)

Property \Doctrine\Tests\ORM\Functional\Ticket\GH10880Process::$currentStage does not have @var annotation for its value.
}

/**
* @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;
}

0 comments on commit 5cb01e6

Please sign in to comment.