Completed
Push — master ( 027344...6c7bb5 )
by Guilherme
64:45 queued 10s
created

GH7824Test::setUp()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 4
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 6
rs 10
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Doctrine\Tests\ORM\Functional\Ticket;
6
7
use Doctrine\ORM\Annotation as ORM;
8
use Doctrine\Tests\OrmFunctionalTestCase;
9
10
/**
11
 * @group GH-7824
12
 */
13
class GH7824Test extends OrmFunctionalTestCase
14
{
15
    protected function setUp() : void
16
    {
17
        parent::setUp();
18
        $this->schemaTool->createSchema([
19
            $this->em->getClassMetadata(GH7824Main::class),
20
            $this->em->getClassMetadata(GH7824Child::class),
21
        ]);
22
    }
23
24
    /**
25
     * Verifies that joined subclasses can contain non-ORM properties.
26
     */
27
    public function testIssue()
28
    {
29
        // Test insert
30
        $child               = new GH7824Child();
31
        $child->name         = 'Sam';
32
        $child->someProperty = 'foo';
33
        $this->em->persist($child);
34
        $this->em->flush();
35
        self::assertEquals($child->someProperty, 'foo');
36
37
        // Test update
38
        $child->name = 'Bob';
39
        $this->em->flush();
40
        $this->em->clear();
41
42
        // Test find
43
        $child = $this->em->getRepository(GH7824Child::class)->find(1);
44
        self::assertEquals($child->name, 'Bob');
45
        self::assertEquals($child->someProperty, null);
46
    }
47
}
48
49
/**
50
 * @ORM\Entity
51
 * @ORM\InheritanceType("JOINED")
52
 * @ORM\DiscriminatorMap({"child" = "Doctrine\Tests\ORM\Functional\Ticket\GH7824Child"})
53
 */
54
abstract class GH7824Main
55
{
56
    /**
57
     * @ORM\Id
58
     * @ORM\Column(type="integer")
59
     * @ORM\GeneratedValue
60
     */
61
    public $id;
62
}
63
64
/**
65
 * @ORM\Entity
66
 */
67
class GH7824Child extends GH7824Main
68
{
69
    /** @ORM\Column(type="string") */
70
    public $name;
71
    public $someProperty; // Not a column
72
}
73