File: GH8415ToManyAssociationTest.php

package info (click to toggle)
doctrine 3.5.1%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites:
  • size: 11,552 kB
  • sloc: php: 108,302; xml: 1,340; makefile: 35; sh: 14
file content (66 lines) | stat: -rw-r--r-- 1,673 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
<?php

declare(strict_types=1);

namespace Doctrine\Tests\ORM\Functional\Ticket;

use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
use Doctrine\Tests\OrmTestCase;
use PHPUnit\Framework\Attributes\RequiresPhpunit;

#[RequiresPhpunit('< 12')]
class GH8415ToManyAssociationTest extends OrmTestCase
{
    public function testToManyAssociationOnBaseClassAllowedWhenThereAreMappedSuperclassesAsChildren(): void
    {
        $this->expectNotToPerformAssertions();

        $em = $this->getTestEntityManager();
        $em->getClassMetadata(GH8415ToManyLeafClass::class);
    }
}

#[ORM\Entity]
class GH8415ToManyAssociationTarget
{
    /** @var int */
    #[ORM\Column(type: 'integer')]
    #[ORM\Id]
    #[ORM\GeneratedValue]
    public $id;

    /** @var GH8415ToManyBaseClass */
    #[ORM\ManyToOne(targetEntity: GH8415ToManyBaseClass::class, inversedBy: 'targets')]
    public $base;
}

#[ORM\Entity]
#[ORM\InheritanceType('SINGLE_TABLE')]
#[ORM\DiscriminatorColumn(name: 'discriminator', type: 'string')]
#[ORM\DiscriminatorMap(['1' => GH8415ToManyBaseClass::class, '2' => GH8415ToManyLeafClass::class])]
class GH8415ToManyBaseClass
{
    /** @var int */
    #[ORM\Column(type: 'integer')]
    #[ORM\Id]
    #[ORM\GeneratedValue]
    public $id;

    /** @var Collection */
    #[ORM\OneToMany(targetEntity: GH8415ToManyAssociationTarget::class, mappedBy: 'base')]
    public $targets;
}

#[ORM\MappedSuperclass]
class GH8415ToManyMappedSuperclass extends GH8415ToManyBaseClass
{
}

#[ORM\Entity]
class GH8415ToManyLeafClass extends GH8415ToManyMappedSuperclass
{
    /** @var string */
    #[ORM\Column(type: 'string')]
    public $leafField;
}