Skip to content

Commit

Permalink
Merge pull request #10750 from mpdude/7006-fixed
Browse files Browse the repository at this point in the history
Add test to show #7006 has been fixed
  • Loading branch information
greg0ire authored Jun 2, 2023
2 parents 330c0bc + a72a0c3 commit 84ab535
Showing 1 changed file with 135 additions and 0 deletions.
135 changes: 135 additions & 0 deletions tests/Doctrine/Tests/ORM/Functional/Ticket/GH7006Test.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,135 @@
<?php

declare(strict_types=1);

namespace Doctrine\Tests\ORM\Functional\Ticket;

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

class GH7006Test extends OrmFunctionalTestCase
{
protected function setUp(): void
{
parent::setUp();

$this->createSchemaForModels(GH7006Book::class, GH7006PCT::class, GH7006PCTFee::class);
}

public function testIssue(): void
{
$book = new GH7006Book();
$book->exchangeCode = 'first';
$this->_em->persist($book);

$book->exchangeCode = 'second'; // change sth.

$paymentCardTransaction = new GH7006PCT();
$paymentCardTransaction->book = $book;
$paymentCardTransactionFee = new GH7006PCTFee($paymentCardTransaction);

$this->_em->persist($paymentCardTransaction);

$this->_em->flush();

self::assertIsInt($book->id);
self::assertIsInt($paymentCardTransaction->id);
self::assertIsInt($paymentCardTransactionFee->id);
}
}

/**
* @ORM\Entity
*/
class GH7006Book
{
/**
* @ORM\Id
* @ORM\Column(type="integer")
* @ORM\GeneratedValue(strategy="AUTO")
*
* @var int
*/
public $id;

/**
* @ORM\Column(type="string", length=255, nullable=true)
*
* @var string
*/
public $exchangeCode;

/**
* @ORM\OneToOne(targetEntity="GH7006PCT", cascade={"persist", "remove"})
* @ORM\JoinColumn(name="paymentCardTransactionId", referencedColumnName="id")
*
* @var GH7006PCT
*/
public $paymentCardTransaction;
}

/**
* @ORM\Entity
*/
class GH7006PCT
{
/**
* @ORM\Id
* @ORM\Column(type="integer")
* @ORM\GeneratedValue(strategy="AUTO")
*
* @var int
*/
public $id;

/**
* @ORM\ManyToOne(targetEntity="GH7006Book")
* @ORM\JoinColumn(name="bookingId", referencedColumnName="id", nullable=false)
*
* @var GH7006Book
*/
public $book;

/**
* @ORM\OneToMany(targetEntity="GH7006PCTFee", mappedBy="pct", cascade={"persist", "remove"})
* @ORM\OrderBy({"id" = "ASC"})
*
* @var Collection<int, GH7006PCTFee>
*/
public $fees;

public function __construct()
{
$this->fees = new ArrayCollection();
}
}

/**
* @ORM\Entity
*/
class GH7006PCTFee
{
/**
* @ORM\Id
* @ORM\Column(type="integer")
* @ORM\GeneratedValue(strategy="AUTO")
*
* @var int
*/
public $id;

/**
* @ORM\ManyToOne(targetEntity="GH7006PCT", inversedBy="fees")
* @ORM\JoinColumn(name="paymentCardTransactionId", referencedColumnName="id", nullable=false)
*
* @var GH7006PCT
*/
public $pct;

public function __construct(GH7006PCT $pct)
{
$this->pct = $pct;
$pct->fees->add($this);
}
}

0 comments on commit 84ab535

Please sign in to comment.