DDC309Test.php 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. <?php
  2. namespace Doctrine\Tests\ORM\Functional\Ticket;
  3. require_once __DIR__ . '/../../../TestInit.php';
  4. class DDC309Test extends \Doctrine\Tests\OrmFunctionalTestCase
  5. {
  6. protected function setUp()
  7. {
  8. parent::setUp();
  9. $this->_schemaTool->createSchema(array(
  10. $this->_em->getClassMetadata(__NAMESPACE__ . '\DDC309Country'),
  11. $this->_em->getClassMetadata(__NAMESPACE__ . '\DDC309User'),
  12. ));
  13. }
  14. public function testTwoIterateHydrations()
  15. {
  16. $c1 = new DDC309Country();
  17. $c2 = new DDC309Country();
  18. $u1 = new DDC309User();
  19. $u2 = new DDC309User();
  20. $this->_em->persist($c1);
  21. $this->_em->persist($c2);
  22. $this->_em->persist($u1);
  23. $this->_em->persist($u2);
  24. $this->_em->flush();
  25. $this->_em->clear();
  26. $q = $this->_em->createQuery('SELECT c FROM Doctrine\Tests\ORM\Functional\Ticket\DDC309Country c')->iterate();
  27. $c = $q->next();
  28. $this->assertEquals(1, $c[0]->id);
  29. $r = $this->_em->createQuery('SELECT u FROM Doctrine\Tests\ORM\Functional\Ticket\DDC309User u')->iterate();
  30. $u = $r->next(); // This line breaks
  31. $this->assertEquals(1, $u[0]->id);
  32. $c = $q->next();
  33. $u = $r->next();
  34. $this->assertEquals(2, $c[0]->id);
  35. $this->assertEquals(2, $u[0]->id);
  36. }
  37. }
  38. /**
  39. * @Entity
  40. */
  41. class DDC309Country
  42. {
  43. /**
  44. * @Id
  45. * @Column(name="id", type="integer")
  46. * @GeneratedValue
  47. */
  48. public $id;
  49. }
  50. /**
  51. * @Entity
  52. */
  53. class DDC309User
  54. {
  55. /**
  56. * @Id
  57. * @Column(name="id", type="integer")
  58. * @GeneratedValue
  59. */
  60. public $id;
  61. }