2017-06-22 09:50:53 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace Doctrine\Tests\ORM\Functional\Ticket;
|
|
|
|
|
|
|
|
use Doctrine\Tests\OrmFunctionalTestCase;
|
|
|
|
|
|
|
|
class Ticket4646InstanceOfParametricTest extends OrmFunctionalTestCase
|
|
|
|
{
|
2017-08-18 12:35:51 +02:00
|
|
|
protected function setUp(): void
|
2017-06-22 09:50:53 +02:00
|
|
|
{
|
|
|
|
parent::setUp();
|
|
|
|
$this->_schemaTool->createSchema([
|
|
|
|
$this->_em->getClassMetadata(PersonTicket4646Parametric::class),
|
|
|
|
$this->_em->getClassMetadata(EmployeeTicket4646Parametric::class),
|
|
|
|
]);
|
|
|
|
}
|
|
|
|
|
2017-08-18 12:35:51 +02:00
|
|
|
public function testInstanceOf(): void
|
2017-06-22 09:50:53 +02:00
|
|
|
{
|
|
|
|
$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();
|
2017-08-18 12:35:51 +02:00
|
|
|
self::assertCount(2, $result);
|
|
|
|
self::assertContainsOnlyInstancesOf(PersonTicket4646Parametric::class, $result);
|
2017-06-22 09:50:53 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @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;
|
|
|
|
|
2017-08-18 12:35:51 +02:00
|
|
|
public function getId(): ?int
|
2017-06-22 09:50:53 +02:00
|
|
|
{
|
|
|
|
return $this->id;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @Entity()
|
|
|
|
* @Table(name="instance_of_parametric_employee")
|
|
|
|
*/
|
|
|
|
class EmployeeTicket4646Parametric extends PersonTicket4646Parametric
|
|
|
|
{
|
|
|
|
}
|