DDC1250Test.php 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. <?php
  2. namespace Doctrine\Tests\ORM\Functional\Ticket;
  3. use Doctrine\Common\Collections\ArrayCollection;
  4. use Doctrine\Tests\Models\CMS\CmsEmployee;
  5. require_once __DIR__ . '/../../../TestInit.php';
  6. /**
  7. * @group DDC-1250
  8. */
  9. class DDC1250Test extends \Doctrine\Tests\OrmFunctionalTestCase
  10. {
  11. public function setUp()
  12. {
  13. parent::setUp();
  14. try {
  15. $this->_schemaTool->createSchema(array(
  16. $this->_em->getClassMetadata(__NAMESPACE__ . '\\DDC1250ClientHistory'),
  17. ));
  18. } catch(\PDOException $e) {
  19. }
  20. }
  21. public function testIssue()
  22. {
  23. $c1 = new DDC1250ClientHistory;
  24. $c2 = new DDC1250ClientHistory;
  25. $c1->declinedClientsHistory = $c2;
  26. $c1->declinedBy = $c2;
  27. $c2->declinedBy = $c1;
  28. $c2->declinedClientsHistory= $c1;
  29. $this->_em->persist($c1);
  30. $this->_em->persist($c2);
  31. $this->_em->flush();
  32. $this->_em->clear();
  33. $history = $this->_em->createQuery('SELECT h FROM ' . __NAMESPACE__ . '\\DDC1250ClientHistory h WHERE h.id = ?1')
  34. ->setParameter(1, $c2->id)->getSingleResult();
  35. $this->assertInstanceOf(__NAMESPACE__ . '\\DDC1250ClientHistory', $history);
  36. }
  37. }
  38. /**
  39. * @Entity
  40. */
  41. class DDC1250ClientHistory
  42. {
  43. /** @Id @GeneratedValue @Column(type="integer") */
  44. public $id;
  45. /** @OneToOne(targetEntity="DDC1250ClientHistory", inversedBy="declinedBy")
  46. * @JoinColumn(name="declined_clients_history_id", referencedColumnName="id")
  47. */
  48. public $declinedClientsHistory;
  49. /**
  50. * @OneToOne(targetEntity="DDC1250ClientHistory", mappedBy="declinedClientsHistory")
  51. * @var
  52. */
  53. public $declinedBy;
  54. }
  55. /**
  56. *
  57. Entities\ClientsHistory:
  58. type: entity
  59. table: clients_history
  60. fields:
  61. id:
  62. id: true
  63. type: integer
  64. unsigned: false
  65. nullable: false
  66. generator:
  67. strategy: IDENTITY
  68. [...skiped...]
  69. oneToOne:
  70. declinedClientsHistory:
  71. targetEntity: Entities\ClientsHistory
  72. joinColumn:
  73. name: declined_clients_history_id
  74. referencedColumnName: id
  75. inversedBy: declinedBy
  76. declinedBy:
  77. targetEntity: Entities\ClientsHistory
  78. mappedBy: declinedClientsHistory
  79. lifecycleCallbacks: { }
  80. repositoryClass: Entities\ClientsHistoryRepository
  81. */