forked from doctrine/orm
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add test to demonstrate doctrine#6499 persistence ordering bug on non…
…-nullable cascading relationship
- Loading branch information
Showing
1 changed file
with
81 additions
and
0 deletions.
There are no files selected for viewing
81 changes: 81 additions & 0 deletions
81
tests/Doctrine/Tests/ORM/Functional/Ticket/DDC6499Test.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,81 @@ | ||
<?php | ||
|
||
namespace Doctrine\Tests\ORM\Functional\Ticket; | ||
|
||
use Doctrine\Tests\OrmFunctionalTestCase; | ||
|
||
/** | ||
* @group DDC-6499 | ||
*/ | ||
class DDC6499Test extends OrmFunctionalTestCase | ||
{ | ||
protected function setUp(): void | ||
{ | ||
parent::setUp(); | ||
|
||
$this->_schemaTool->createSchema( | ||
[ | ||
$this->_em->getClassMetadata(DDC6499A::class), | ||
$this->_em->getClassMetadata(DDC6499B::class), | ||
] | ||
); | ||
} | ||
|
||
protected function tearDown(): void | ||
{ | ||
parent::tearDown(); | ||
|
||
$this->_schemaTool->dropSchema( | ||
[ | ||
$this->_em->getClassMetadata(DDC6499A::class), | ||
$this->_em->getClassMetadata(DDC6499B::class), | ||
] | ||
); | ||
} | ||
|
||
/** | ||
* Test for the bug described in issue #6499. | ||
*/ | ||
public function testIssue(): void | ||
{ | ||
$a = new DDC6499A(); | ||
|
||
$this->_em->flush(); | ||
$this->_em->clear(); | ||
|
||
self::assertEquals($this->_em->find(DDC6499A::class, $a->id)->b->id, $a->b->id, 'Issue #6499 will result in a Integrity constraint violation before reaching this point.'); | ||
} | ||
} | ||
|
||
/** @Entity */ | ||
class DDC6499A | ||
{ | ||
/** | ||
* @Id | ||
* @Column(type="integer") | ||
* @GeneratedValue | ||
*/ | ||
public $id; | ||
|
||
/** | ||
* @OneToOne(targetEntity="DDC6499B", cascade={"persist"}) | ||
* @JoinColumn(nullable=false) | ||
*/ | ||
public $b; | ||
|
||
public function __construct() | ||
{ | ||
$this->b = new DDC6499B(); | ||
} | ||
} | ||
|
||
/** @Entity */ | ||
class DDC6499B | ||
{ | ||
/** | ||
* @Id | ||
* @Column(type="integer") | ||
* @GeneratedValue | ||
*/ | ||
public $id; | ||
} |