-
-
Save arnaud-lb/2ac4a3007bba08ca5f8fa78cfc353cf5 to your computer and use it in GitHub Desktop.
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
<?php | |
/** | |
* @Entity | |
*/ | |
class A | |
{ | |
/** | |
* @GeneratedValue() | |
* @Id @Column(type="integer") | |
*/ | |
public $id; | |
/** | |
* @OneToOne(targetEntity="B", inversedBy="a") | |
* @JoinColumn(nullable=false) | |
*/ | |
public $b; | |
} | |
/** | |
* @Entity | |
*/ | |
class B | |
{ | |
/** | |
* @GeneratedValue() | |
* @Id @Column(type="integer") | |
*/ | |
public $id; | |
/** | |
* @OneToOne(targetEntity="A", mappedBy="b") | |
* @JoinColumn(nullable=true) | |
*/ | |
public $a; | |
} | |
/** | |
* @Entity | |
*/ | |
class C | |
{ | |
/** | |
* @GeneratedValue() | |
* @Id @Column(type="integer") | |
*/ | |
public $id; | |
/** | |
* @ManyToOne(targetEntity="A") | |
* @JoinColumn(nullable=false) | |
*/ | |
public $a; | |
} |
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
<?php | |
class BugTest extends \Doctrine\Tests\OrmFunctionalTestCase { | |
protected function setUp() { | |
parent::setUp(); | |
$this->_schemaTool->createSchema( | |
[ | |
$this->_em->getClassMetadata(A::class), | |
$this->_em->getClassMetadata(B::class), | |
$this->_em->getClassMetadata(C::class), | |
] | |
); | |
} | |
public function testExplicitPersist() | |
{ | |
$a = new A(); | |
$b = new B(); | |
$c = new C(); | |
$a->b = $b; | |
$b->a = $a; | |
$c->a = $a; | |
$this->_em->persist($a); | |
$this->_em->persist($c); | |
$this->_em->persist($b); | |
$this->_em->flush(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment