DDC1193Test.php 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. <?php
  2. namespace Doctrine\Tests\ORM\Functional\Ticket;
  3. require_once __DIR__ . '/../../../TestInit.php';
  4. use DateTime, Doctrine\DBAL\Types\Type;
  5. class DDC1193Test extends \Doctrine\Tests\OrmFunctionalTestCase
  6. {
  7. protected function setUp()
  8. {
  9. parent::setUp();
  10. //$this->_em->getConnection()->getConfiguration()->setSQLLogger(new \Doctrine\DBAL\Logging\EchoSQLLogger);
  11. $this->_schemaTool->createSchema(array(
  12. $this->_em->getClassMetadata(__NAMESPACE__ . '\DDC1193Company'),
  13. $this->_em->getClassMetadata(__NAMESPACE__ . '\DDC1193Person'),
  14. $this->_em->getClassMetadata(__NAMESPACE__ . '\DDC1193Account')
  15. ));
  16. }
  17. /**
  18. * @group DDC-1193
  19. */
  20. public function testIssue()
  21. {
  22. $company = new DDC1193Company();
  23. $person = new DDC1193Person();
  24. $account = new DDC1193Account();
  25. $person->account = $account;
  26. $person->company = $company;
  27. $company->member = $person;
  28. $this->_em->persist($company);
  29. $this->_em->flush();
  30. $companyId = $company->id;
  31. $accountId = $account->id;
  32. $this->_em->clear();
  33. $company = $this->_em->find(get_class($company), $companyId);
  34. $this->assertTrue($this->_em->getUnitOfWork()->isInIdentityMap($company), "Company is in identity map.");
  35. $this->assertFalse($company->member->__isInitialized__, "Pre-Condition");
  36. $this->assertTrue($this->_em->getUnitOfWork()->isInIdentityMap($company->member), "Member is in identity map.");
  37. $this->_em->remove($company);
  38. $this->_em->flush();
  39. $this->assertEquals(count($this->_em->getRepository(get_class($account))->findAll()), 0);
  40. }
  41. }
  42. /** @Entity */
  43. class DDC1193Company {
  44. /**
  45. * @Id @Column(type="integer")
  46. * @GeneratedValue
  47. */
  48. public $id;
  49. /** @OneToOne(targetEntity="DDC1193Person", cascade={"persist", "remove"}) */
  50. public $member;
  51. }
  52. /** @Entity */
  53. class DDC1193Person {
  54. /**
  55. * @Id @Column(type="integer")
  56. * @GeneratedValue
  57. */
  58. public $id;
  59. /**
  60. * @OneToOne(targetEntity="DDC1193Account", cascade={"persist", "remove"})
  61. */
  62. public $account;
  63. }
  64. /** @Entity */
  65. class DDC1193Account {
  66. /**
  67. * @Id @Column(type="integer")
  68. * @GeneratedValue
  69. */
  70. public $id;
  71. }