DDC1300Test.php 2.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. <?php
  2. namespace Doctrine\Tests\ORM\Functional\Ticket;
  3. require_once __DIR__ . '/../../../TestInit.php';
  4. /**
  5. * @group DDC-1300
  6. */
  7. class DDC1300Test extends \Doctrine\Tests\OrmFunctionalTestCase
  8. {
  9. public function setUp()
  10. {
  11. parent::setUp();
  12. $this->_schemaTool->createSchema(array(
  13. $this->_em->getClassMetadata(__NAMESPACE__ . '\\DDC1300Foo'),
  14. $this->_em->getClassMetadata(__NAMESPACE__ . '\\DDC1300FooLocale'),
  15. ));
  16. }
  17. public function testIssue()
  18. {
  19. $foo = new DDC1300Foo();
  20. $foo->_fooReference = "foo";
  21. $this->_em->persist($foo);
  22. $this->_em->flush();
  23. $locale = new DDC1300FooLocale();
  24. $locale->_foo = $foo;
  25. $locale->_locale = "en";
  26. $locale->_title = "blub";
  27. $this->_em->persist($locale);
  28. $this->_em->flush();
  29. $query = $this->_em->createQuery('SELECT f, fl FROM Doctrine\Tests\ORM\Functional\Ticket\DDC1300Foo f JOIN f._fooLocaleRefFoo fl');
  30. $result = $query->getResult();
  31. $this->assertEquals(1, count($result));
  32. }
  33. }
  34. /**
  35. * @Entity
  36. */
  37. class DDC1300Foo
  38. {
  39. /**
  40. * @var integer fooID
  41. * @Column(name="fooID", type="integer", nullable=false)
  42. * @GeneratedValue(strategy="AUTO")
  43. * @Id
  44. */
  45. public $_fooID = null;
  46. /**
  47. * @var string fooReference
  48. * @Column(name="fooReference", type="string", nullable=true, length=45)
  49. */
  50. public $_fooReference = null;
  51. /**
  52. * @OneToMany(targetEntity="DDC1300FooLocale", mappedBy="_foo",
  53. * cascade={"persist"})
  54. */
  55. public $_fooLocaleRefFoo = null;
  56. /**
  57. * Constructor
  58. *
  59. * @param array|Zend_Config|null $options
  60. * @return Bug_Model_Foo
  61. */
  62. public function __construct($options = null)
  63. {
  64. $this->_fooLocaleRefFoo = new \Doctrine\Common\Collections\ArrayCollection();
  65. }
  66. }
  67. /**
  68. * @Entity
  69. */
  70. class DDC1300FooLocale
  71. {
  72. /**
  73. * @ManyToOne(targetEntity="DDC1300Foo")
  74. * @JoinColumn(name="fooID", referencedColumnName="fooID")
  75. * @Id
  76. */
  77. public $_foo = null;
  78. /**
  79. * @var string locale
  80. * @Column(name="locale", type="string", nullable=false, length=5)
  81. * @Id
  82. */
  83. public $_locale = null;
  84. /**
  85. * @var string title
  86. * @Column(name="title", type="string", nullable=true, length=150)
  87. */
  88. public $_title = null;
  89. }