Skip to content

Instantly share code, notes, and snippets.

@arnaud-lb
Last active April 12, 2018 14:49
Show Gist options
  • Save arnaud-lb/2ac4a3007bba08ca5f8fa78cfc353cf5 to your computer and use it in GitHub Desktop.
Save arnaud-lb/2ac4a3007bba08ca5f8fa78cfc353cf5 to your computer and use it in GitHub Desktop.
<?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;
}
<?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