Failed Conditions
Pull Request — master (#6392)
by Alessandro
18:37
created

Ticket4646InstanceOfAbstractTest::testInstanceOf()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 13
Code Lines 8

Duplication

Lines 13
Ratio 100 %

Importance

Changes 0
Metric Value
dl 13
loc 13
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 8
nc 1
nop 0
1
<?php
2
3
namespace Doctrine\Tests\ORM\Functional\Ticket;
4
5
use Doctrine\Tests\OrmFunctionalTestCase;
6
7 View Code Duplication
class Ticket4646InstanceOfAbstractTest extends OrmFunctionalTestCase
0 ignored issues
show
Duplication introduced by
This class seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
8
{
9
    protected function setUp()
10
    {
11
        parent::setUp();
12
13
        $this->_schemaTool->createSchema([
14
            $this->_em->getClassMetadata(PersonTicket4646Abstract::class),
15
            $this->_em->getClassMetadata(EmployeeTicket4646Abstract::class),
16
        ]);
17
    }
18
19
    public function testInstanceOf()
20
    {
21
        $this->_em->persist(new EmployeeTicket4646Abstract());
22
        $this->_em->flush();
23
24
        $dql = 'SELECT p FROM Doctrine\Tests\ORM\Functional\Ticket\PersonTicket4646Abstract p
25
                WHERE p INSTANCE OF Doctrine\Tests\ORM\Functional\Ticket\PersonTicket4646Abstract';
26
        $query = $this->_em->createQuery($dql);
27
        $result = $query->getResult();
28
29
        $this->assertCount(1, $result);
30
        $this->assertContainsOnlyInstancesOf(PersonTicket4646Abstract::class, $result);
31
    }
32
}
33
34
/**
35
 * @Entity()
36
 * @Table(name="instance_of_abstract_test_person")
37
 * @InheritanceType(value="JOINED")
38
 * @DiscriminatorColumn(name="kind", type="string")
39
 * @DiscriminatorMap(value={
40
 *     "employee": EmployeeTicket4646Abstract::class
41
 * })
42
 */
43
abstract class PersonTicket4646Abstract
44
{
45
    /**
46
     * @Id()
47
     * @GeneratedValue()
48
     * @Column(type="integer")
49
     */
50
    private $id;
51
52
    public function getId()
53
    {
54
        return $this->id;
55
    }
56
}
57
58
/**
59
 * @Entity()
60
 * @Table(name="instance_of_abstract_test_employee")
61
 */
62
class EmployeeTicket4646Abstract extends PersonTicket4646Abstract
63
{
64
}
65