@@ 7-35 (lines=29) @@ | ||
4 | ||
5 | use Doctrine\Tests\OrmFunctionalTestCase; |
|
6 | ||
7 | class Ticket4646InstanceOfMultiLevelTest extends OrmFunctionalTestCase |
|
8 | { |
|
9 | protected function setUp() |
|
10 | { |
|
11 | parent::setUp(); |
|
12 | ||
13 | $this->_schemaTool->createSchema([ |
|
14 | $this->_em->getClassMetadata(PersonTicket4646MultiLevel::class), |
|
15 | $this->_em->getClassMetadata(EmployeeTicket4646MultiLevel::class), |
|
16 | $this->_em->getClassMetadata(EngineerTicket4646MultiLevel::class), |
|
17 | ]); |
|
18 | } |
|
19 | ||
20 | public function testInstanceOf() |
|
21 | { |
|
22 | $this->_em->persist(new PersonTicket4646MultiLevel()); |
|
23 | $this->_em->persist(new EmployeeTicket4646MultiLevel()); |
|
24 | $this->_em->persist(new EngineerTicket4646MultiLevel()); |
|
25 | $this->_em->flush(); |
|
26 | ||
27 | $dql = 'SELECT p FROM Doctrine\Tests\ORM\Functional\Ticket\PersonTicket4646MultiLevel p |
|
28 | WHERE p INSTANCE OF Doctrine\Tests\ORM\Functional\Ticket\PersonTicket4646MultiLevel'; |
|
29 | $query = $this->_em->createQuery($dql); |
|
30 | $result = $query->getResult(); |
|
31 | ||
32 | $this->assertCount(3, $result); |
|
33 | $this->assertContainsOnlyInstancesOf(PersonTicket4646MultiLevel::class, $result); |
|
34 | } |
|
35 | } |
|
36 | ||
37 | /** |
|
38 | * @Entity() |
@@ 7-34 (lines=28) @@ | ||
4 | ||
5 | use Doctrine\Tests\OrmFunctionalTestCase; |
|
6 | ||
7 | class Ticket4646InstanceOfParametricTest extends OrmFunctionalTestCase |
|
8 | { |
|
9 | protected function setUp() |
|
10 | { |
|
11 | parent::setUp(); |
|
12 | $this->_schemaTool->createSchema([ |
|
13 | $this->_em->getClassMetadata(PersonTicket4646Parametric::class), |
|
14 | $this->_em->getClassMetadata(EmployeeTicket4646Parametric::class), |
|
15 | ]); |
|
16 | } |
|
17 | ||
18 | public function testInstanceOf() |
|
19 | { |
|
20 | $this->_em->persist(new PersonTicket4646Parametric()); |
|
21 | $this->_em->persist(new EmployeeTicket4646Parametric()); |
|
22 | $this->_em->flush(); |
|
23 | $dql = 'SELECT p FROM Doctrine\Tests\ORM\Functional\Ticket\PersonTicket4646Parametric p |
|
24 | WHERE p INSTANCE OF :parameter'; |
|
25 | $query = $this->_em->createQuery($dql); |
|
26 | $query->setParameter( |
|
27 | 'parameter', |
|
28 | $this->_em->getClassMetadata(PersonTicket4646Parametric::class) |
|
29 | ); |
|
30 | $result = $query->getResult(); |
|
31 | $this->assertCount(2, $result); |
|
32 | $this->assertContainsOnlyInstancesOf(PersonTicket4646Parametric::class, $result); |
|
33 | } |
|
34 | } |
|
35 | ||
36 | /** |
|
37 | * @Entity() |