From b1f7c59ed560af7770d2ff649d7461605253d1cd Mon Sep 17 00:00:00 2001 From: Alessandro Lai Date: Thu, 22 Jun 2017 09:50:53 +0200 Subject: [PATCH] Adding a failing test case for parameter binding using metadata with INSTANCE OF --- .../Ticket4646InstanceOfParametricTest.php | 67 +++++++++++++++++++ 1 file changed, 67 insertions(+) create mode 100644 tests/Doctrine/Tests/ORM/Functional/Ticket/Ticket4646InstanceOfParametricTest.php diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/Ticket4646InstanceOfParametricTest.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/Ticket4646InstanceOfParametricTest.php new file mode 100644 index 000000000..302934e8c --- /dev/null +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/Ticket4646InstanceOfParametricTest.php @@ -0,0 +1,67 @@ +_schemaTool->createSchema([ + $this->_em->getClassMetadata(PersonTicket4646Parametric::class), + $this->_em->getClassMetadata(EmployeeTicket4646Parametric::class), + ]); + } + + public function testInstanceOf() + { + $this->_em->persist(new PersonTicket4646Parametric()); + $this->_em->persist(new EmployeeTicket4646Parametric()); + $this->_em->flush(); + $dql = 'SELECT p FROM Doctrine\Tests\ORM\Functional\Ticket\PersonTicket4646Parametric p + WHERE p INSTANCE OF :parameter'; + $query = $this->_em->createQuery($dql); + $query->setParameter( + 'parameter', + $this->_em->getClassMetadata(PersonTicket4646Parametric::class) + ); + $result = $query->getResult(); + $this->assertCount(2, $result); + $this->assertContainsOnlyInstancesOf(PersonTicket4646Parametric::class, $result); + } +} + +/** + * @Entity() + * @Table(name="instance_of_parametric_person") + * @InheritanceType(value="JOINED") + * @DiscriminatorColumn(name="kind", type="string") + * @DiscriminatorMap(value={ + * "person": "Doctrine\Tests\ORM\Functional\Ticket\PersonTicket4646Parametric", + * "employee": "Doctrine\Tests\ORM\Functional\Ticket\EmployeeTicket4646Parametric" + * }) + */ +class PersonTicket4646Parametric +{ + /** + * @Id() + * @GeneratedValue() + * @Column(type="integer") + */ + private $id; + + public function getId() + { + return $this->id; + } +} + +/** + * @Entity() + * @Table(name="instance_of_parametric_employee") + */ +class EmployeeTicket4646Parametric extends PersonTicket4646Parametric +{ +}