Failed Conditions
Pull Request — 2.6 (#7514)
by Joe
06:42
created

GH7512Test::setUp()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 14
Code Lines 9

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 9
nc 1
nop 0
dl 0
loc 14
rs 9.9666
c 0
b 0
f 0
1
<?php declare(strict_types=1);
2
3
namespace Doctrine\Tests\ORM\Functional\Ticket;
4
5
use Doctrine\Tests\OrmFunctionalTestCase;
6
7
class GH7512Test extends OrmFunctionalTestCase
8
{
9
    protected function setUp(): void
10
    {
11
        parent::setUp();
12
13
        $this->setUpEntitySchema([
14
            GH7512EntityA::class,
15
            GH7512EntityB::class,
16
            GH7512EntityC::class
17
        ]);
18
19
        $this->_em->persist(new GH7512EntityA());
20
        $this->_em->persist(new GH7512EntityC());
21
        $this->_em->flush();
22
        $this->_em->clear();
23
    }
24
25
    public function testFindEntityByAssociationPropertyJoinedChildWithClearMetadata(): void
26
    {
27
        // unset metadata for entity B as though it hasn't been touched yet in application lifecycle.
28
        $this->_em->getMetadataFactory()->setMetadataFor(GH7512EntityB::class, null);
29
        $result = $this->_em->getRepository(GH7512EntityC::class)->findBy([
30
            'entityA' => new GH7512EntityB()
31
        ]);
32
        $this->assertEmpty($result);
33
    }
34
}
35
36
/**
37
 * @Entity()
38
 * @InheritanceType("JOINED")
39
 * @DiscriminatorMap({
40
 *     "entitya"=Doctrine\Tests\ORM\Functional\Ticket\GH7512EntityA::class,
41
 *     "entityB"=Doctrine\Tests\ORM\Functional\Ticket\GH7512EntityB::class
42
 * })
43
 */
44
class GH7512EntityA
45
{
46
    /**
47
     * @Column(type="integer")
48
     * @Id()
49
     * @GeneratedValue(strategy="AUTO")
50
     */
51
    private $id;
0 ignored issues
show
introduced by
The private property $id is not used, and could be removed.
Loading history...
52
53
    /**
54
     * @OneToMany(targetEntity="Doctrine\Tests\ORM\Functional\Ticket\GH7512EntityC", mappedBy="entityA")
55
     */
56
    private $entityCs;
0 ignored issues
show
introduced by
The private property $entityCs is not used, and could be removed.
Loading history...
57
}
58
59
/**
60
 * @Entity()
61
 */
62
class GH7512EntityB extends GH7512EntityA
63
{
64
65
}
66
67
/**
68
 * @Entity()
69
 */
70
class GH7512EntityC
71
{
72
    /**
73
     * @Column(type="integer")
74
     * @Id()
75
     * @GeneratedValue(strategy="AUTO")
76
     */
77
    private $id;
78
79
    /**
80
     * @ManyToOne(targetEntity="Doctrine\Tests\ORM\Functional\Ticket\GH7512EntityA", inversedBy="entityCs")
81
     */
82
    private $entityA;
0 ignored issues
show
introduced by
The private property $entityA is not used, and could be removed.
Loading history...
83
}
84