DDC1515Test.php 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. <?php
  2. namespace Doctrine\Tests\ORM\Functional\Ticket;
  3. /**
  4. * @group DDC-1515
  5. */
  6. class DDC1515Test extends \Doctrine\Tests\OrmFunctionalTestCase
  7. {
  8. public function setUp()
  9. {
  10. parent::setUp();
  11. $this->_schemaTool->createSchema(array(
  12. $this->_em->getClassMetadata(__NAMESPACE__ . '\\DDC1515Foo'),
  13. $this->_em->getClassMetadata(__NAMESPACE__ . '\\DDC1515Bar'),
  14. ));
  15. }
  16. public function testIssue()
  17. {
  18. $bar = new DDC1515Bar();
  19. $this->_em->persist($bar);
  20. $this->_em->flush();
  21. $foo = new DDC1515Foo();
  22. $foo->bar = $bar;
  23. $this->_em->persist($foo);
  24. $this->_em->flush();
  25. $this->_em->clear();
  26. $bar = $this->_em->find(__NAMESPACE__ . '\DDC1515Bar', $bar->id);
  27. $this->assertInstanceOf(__NAMESPACE__.'\DDC1515Foo', $bar->foo);
  28. }
  29. }
  30. /**
  31. * @Entity
  32. */
  33. class DDC1515Foo
  34. {
  35. /**
  36. * @OneToOne(targetEntity="DDC1515Bar", inversedBy="foo") @Id
  37. */
  38. public $bar;
  39. }
  40. /**
  41. * @Entity
  42. */
  43. class DDC1515Bar
  44. {
  45. /**
  46. * @Id @Column(type="integer") @GeneratedValue
  47. */
  48. public $id;
  49. /**
  50. * @OneToOne(targetEntity="DDC1515Foo", mappedBy="bar")
  51. */
  52. public $foo;
  53. }