1
0
mirror of synced 2025-02-13 18:53:15 +03:00

#6499 #6533 simplifying test scenario to the bone, adding description of what happened at persistence-level

This commit is contained in:
Marco Pivetta 2017-08-11 22:05:00 +02:00
parent ebd521c56e
commit 25829ea450
No known key found for this signature in database
GPG Key ID: 4167D3337FD9D629

View File

@ -6,7 +6,12 @@ use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Tests\OrmFunctionalTestCase; use Doctrine\Tests\OrmFunctionalTestCase;
/** /**
* @group DDC-6499 * @group #6499
*
*
* Specifically, DDC6499B has a dependency on DDC6499A, and DDC6499A
* has a dependency on DDC6499B. Since DDC6499A#b is not nullable,
* the DDC6499B should be inserted first.
*/ */
class DDC6499Test extends OrmFunctionalTestCase class DDC6499Test extends OrmFunctionalTestCase
{ {
@ -36,69 +41,56 @@ class DDC6499Test extends OrmFunctionalTestCase
]); ]);
} }
/**
* Test for the bug described in issue #6499.
*/
public function testIssue() : void public function testIssue() : void
{ {
$a = new DDC6499A();
$this->_em->persist($a);
$b = new DDC6499B(); $b = new DDC6499B();
$a->b = $b; $a = new DDC6499A($b);
$this->_em->persist($a);
$this->_em->persist($b); $this->_em->persist($b);
$this->_em->flush(); $this->_em->flush();
$this->_em->clear();
self::assertEquals($this->_em->find(DDC6499A::class, $a->id)->b->id, $b->id, "Issue #6499 will result in a Integrity constraint violation before reaching this point."); self::assertInternalType('integer', $a->id);
self::assertInternalType('integer', $b->id);
} }
/**
* Test for the bug described in issue #6499 (reversed order).
*/
public function testIssueReversed() : void public function testIssueReversed() : void
{ {
$a = new DDC6499A();
$b = new DDC6499B(); $b = new DDC6499B();
$a->b = $b; $a = new DDC6499A($b);
$this->_em->persist($b); $this->_em->persist($b);
$this->_em->persist($a); $this->_em->persist($a);
$this->_em->flush(); $this->_em->flush();
$this->_em->clear();
self::assertEquals($this->_em->find(DDC6499A::class, $a->id)->b->id, $b->id, "Issue #6499 will result in a Integrity constraint violation before reaching this point."); self::assertInternalType('integer', $a->id);
self::assertInternalType('integer', $b->id);
} }
} }
/** @Entity */ /** @Entity */
class DDC6499A class DDC6499A
{ {
/** /** @Id @Column(type="integer") @GeneratedValue */
* @Id @Column(type="integer") @GeneratedValue
*/
public $id; public $id;
/** /** @JoinColumn(nullable=false) @OneToOne(targetEntity=DDC6499B::class) */
* @OneToOne(targetEntity="DDC6499B")
* @JoinColumn(nullable=false)
*/
public $b; public $b;
public function __construct(DDC6499B $b)
{
$this->b = $b;
}
} }
/** @Entity */ /** @Entity */
class DDC6499B class DDC6499B
{ {
/** /** @Id @Column(type="integer") @GeneratedValue */
* @Id @Column(type="integer") @GeneratedValue
*/
public $id; public $id;
/** /** @ManyToOne(targetEntity="DDC6499A") */
* @ManyToOne(targetEntity="DDC6499A", inversedBy="bs") private $a;
*/
public $a;
} }