Passed
Pull Request — master (#7828)
by
unknown
10:13
created

GH7824Test   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 35
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 17
c 1
b 0
f 0
dl 0
loc 35
rs 10
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A testIssue() 0 19 1
A setUp() 0 7 1
1
<?php
2
declare(strict_types=1);
0 ignored issues
show
introduced by
Expected 2 newlines between PHP open tag and declare statement, found 1.
Loading history...
3
4
namespace Doctrine\Tests\ORM\Functional\Ticket;
0 ignored issues
show
introduced by
Expected 1 lines after namespace statement, found 0.
Loading history...
5
use Doctrine\ORM\Annotation as ORM;
0 ignored issues
show
introduced by
Expected 1 lines before first use statement, found 0.
Loading history...
6
use Doctrine\Tests\OrmFunctionalTestCase;
7
8
/**
9
 * @group GH-7824
10
 */
11
class GH7824Test extends OrmFunctionalTestCase
12
{
13
    protected function setUp(): void
0 ignored issues
show
introduced by
There must be exactly 1 whitespace between closing parenthesis and return type colon.
Loading history...
14
    {
15
        parent::setUp();
16
        $this->schemaTool->createSchema(
17
            [
18
            $this->em->getClassMetadata(GH7824Main::class),
0 ignored issues
show
Coding Style introduced by
Array key not indented correctly; expected 16 spaces but found 12
Loading history...
19
            $this->em->getClassMetadata(GH7824Child::class),
0 ignored issues
show
Coding Style introduced by
Array key not indented correctly; expected 16 spaces but found 12
Loading history...
20
            ]
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();
0 ignored issues
show
Coding Style introduced by
Equals sign not aligned with surrounding assignments; expected 15 spaces but found 1 space

This check looks for multiple assignments in successive lines of code. It will report an issue if the operators are not in a straight line.

To visualize

$a = "a";
$ab = "ab";
$abc = "abc";

will produce issues in the first and second line, while this second example

$a   = "a";
$ab  = "ab";
$abc = "abc";

will produce no issues.

Loading history...
31
        $child->name = 'Sam';
0 ignored issues
show
Coding Style introduced by
Equals sign not aligned with surrounding assignments; expected 9 spaces but found 1 space

This check looks for multiple assignments in successive lines of code. It will report an issue if the operators are not in a straight line.

To visualize

$a = "a";
$ab = "ab";
$abc = "abc";

will produce issues in the first and second line, while this second example

$a   = "a";
$ab  = "ab";
$abc = "abc";

will produce no issues.

Loading history...
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
    /**
0 ignored issues
show
introduced by
Found multi-line comment for property \Doctrine\Tests\ORM\Functional\Ticket\GH7824Child::$name with single line content, use one-line comment instead.
Loading history...
70
     * @ORM\Column(type="string")
71
     */
72
    public $name;
73
    public $someProperty; // Not a column
74
}
75