DDC1225Test.php 1.9KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  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-1225
  8. */
  9. class DDC1225Test 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__ . '\\DDC1225_TestEntity1'),
  17. $this->_em->getClassMetadata(__NAMESPACE__ . '\\DDC1225_TestEntity2'),
  18. ));
  19. } catch(\PDOException $e) {
  20. }
  21. }
  22. public function testIssue()
  23. {
  24. $qb = $this->_em->createQueryBuilder();
  25. $qb->from('Doctrine\Tests\ORM\Functional\Ticket\DDC1225_TestEntity1', 'te1')
  26. ->select('te1')
  27. ->where('te1.testEntity2 = ?1')
  28. ->setParameter(1, 0);
  29. $this->assertEquals(
  30. 'SELECT t0_.test_entity2_id AS test_entity2_id0 FROM te1 t0_ WHERE t0_.test_entity2_id = ?',
  31. $qb->getQuery()->getSQL()
  32. );
  33. }
  34. }
  35. /**
  36. * @Entity
  37. * @Table(name="te1")
  38. */
  39. class DDC1225_TestEntity1
  40. {
  41. /**
  42. * @Id
  43. * @ManyToOne(targetEntity="Doctrine\Tests\ORM\Functional\Ticket\DDC1225_TestEntity2")
  44. * @JoinColumn(name="test_entity2_id", referencedColumnName="id", nullable=false)
  45. */
  46. private $testEntity2;
  47. /**
  48. * @param DDC1225_TestEntity2 $testEntity2
  49. */
  50. public function setTestEntity2(DDC1225_TestEntity2 $testEntity2)
  51. {
  52. $this->testEntity2 = $testEntity2;
  53. }
  54. /**
  55. * @return DDC1225_TestEntity2
  56. */
  57. public function getTestEntity2()
  58. {
  59. return $this->testEntity2;
  60. }
  61. }
  62. /**
  63. * @Entity
  64. * @Table(name="te2")
  65. */
  66. class DDC1225_TestEntity2
  67. {
  68. /**
  69. * @Id
  70. * @GeneratedValue(strategy="AUTO")
  71. * @Column(type="integer")
  72. */
  73. private $id;
  74. }