1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Doctrine\Tests\ORM\Functional\Ticket; |
4
|
|
|
|
5
|
|
|
use Doctrine\ORM\Tools\Pagination\Paginator; |
6
|
|
|
|
7
|
|
|
/** |
8
|
|
|
* @group issue-6189 |
9
|
|
|
*/ |
10
|
|
|
class Issue6189Test extends \Doctrine\Tests\OrmFunctionalTestCase |
11
|
|
|
{ |
12
|
|
|
public function setUp() |
13
|
|
|
{ |
14
|
|
|
parent::setUp(); |
15
|
|
|
|
16
|
|
|
$this->_schemaTool->createSchema([ |
17
|
|
|
$this->_em->getClassMetadata(Issue6189Product::CLASSNAME), |
18
|
|
|
$this->_em->getClassMetadata(Issue6189ProductA::CLASSNAME), |
19
|
|
|
$this->_em->getClassMetadata(Issue6189ProductB::CLASSNAME), |
20
|
|
|
]); |
21
|
|
|
} |
22
|
|
|
|
23
|
|
|
public function testSimpleArrayTypeHydratedCorrectlyInJoinedInheritance() |
24
|
|
|
{ |
25
|
|
|
$productA = new Issue6189ProductA(); |
26
|
|
|
|
27
|
|
|
$this->_em->persist($productA); |
28
|
|
|
$this->_em->persist(new Issue6189ProductB()); |
29
|
|
|
|
30
|
|
|
$this->_em->flush(); |
31
|
|
|
|
32
|
|
|
$qb = $this |
33
|
|
|
->_em |
34
|
|
|
->createQueryBuilder(); |
35
|
|
|
|
36
|
|
|
$paginator = new Paginator( |
37
|
|
|
$qb |
38
|
|
|
->select('p') |
39
|
|
|
->from(Issue6189Product::CLASSNAME, 'p') |
40
|
|
|
->where($qb->expr()->isInstanceOf('p', ':productType')) |
41
|
|
|
->setParameter('productType', $this->_em->getClassMetadata(Issue6189ProductA::CLASSNAME)) |
42
|
|
|
->setMaxResults(10) |
43
|
|
|
); |
44
|
|
|
|
45
|
|
|
self::assertCount(1, $paginator); |
46
|
|
|
self::assertSame([$productA], iterator_to_array($paginator)); |
47
|
|
|
} |
48
|
|
|
} |
49
|
|
|
|
50
|
|
|
/** |
51
|
|
|
* @Entity |
52
|
|
|
* @InheritanceType("JOINED") |
53
|
|
|
* @DiscriminatorColumn(name="discr", type="string") |
54
|
|
|
* @DiscriminatorMap({ |
55
|
|
|
* "productA" = Issue6189ProductA::class, |
56
|
|
|
* "productB" = Issue6189ProductB::class, |
57
|
|
|
* }) |
58
|
|
|
*/ |
59
|
|
|
abstract class Issue6189Product |
60
|
|
|
{ |
61
|
|
|
const CLASSNAME = __CLASS__; |
62
|
|
|
|
63
|
|
|
/** |
64
|
|
|
* @var int |
65
|
|
|
* |
66
|
|
|
* @Column(type="integer") |
67
|
|
|
* @GeneratedValue(strategy="AUTO") |
68
|
|
|
* @Id |
69
|
|
|
*/ |
70
|
|
|
public $id; |
71
|
|
|
} |
72
|
|
|
|
73
|
|
|
/** |
74
|
|
|
* @Entity |
75
|
|
|
*/ |
76
|
|
|
class Issue6189ProductA extends Issue6189Product |
77
|
|
|
{ |
78
|
|
|
const CLASSNAME = __CLASS__; |
79
|
|
|
} |
80
|
|
|
|
81
|
|
|
/** |
82
|
|
|
* @Entity |
83
|
|
|
*/ |
84
|
|
|
class Issue6189ProductB extends Issue6189Product |
85
|
|
|
{ |
86
|
|
|
const CLASSNAME = __CLASS__; |
87
|
|
|
} |
88
|
|
|
|