|
| 1 | +<?php |
| 2 | + |
| 3 | +declare(strict_types=1); |
| 4 | + |
| 5 | +namespace Doctrine\Tests\ORM\Functional\Ticket; |
| 6 | + |
| 7 | +use Doctrine\DBAL\Platforms\PostgreSQLPlatform; |
| 8 | +use Doctrine\ORM\Mapping as ORM; |
| 9 | +use Doctrine\Tests\OrmFunctionalTestCase; |
| 10 | + |
| 11 | +/** |
| 12 | + * @group GH-10927 |
| 13 | + */ |
| 14 | +class GH10927Test extends OrmFunctionalTestCase |
| 15 | +{ |
| 16 | + protected function setUp(): void |
| 17 | + { |
| 18 | + parent::setUp(); |
| 19 | + |
| 20 | + $platform = $this->_em->getConnection()->getDatabasePlatform(); |
| 21 | + if (! $platform instanceof PostgreSQLPlatform) { |
| 22 | + self::markTestSkipped('The ' . self::class . ' requires the use of postgresql.'); |
| 23 | + } |
| 24 | + |
| 25 | + $this->setUpEntitySchema([ |
| 26 | + GH10927RootMappedSuperclass::class, |
| 27 | + GH10927InheritedMappedSuperclass::class, |
| 28 | + GH10927EntityA::class, |
| 29 | + GH10927EntityB::class, |
| 30 | + GH10927EntityC::class, |
| 31 | + ]); |
| 32 | + } |
| 33 | + |
| 34 | + public function testSequenceGeneratorDefinitionForRootMappedSuperclass(): void |
| 35 | + { |
| 36 | + $metadata = $this->_em->getClassMetadata(GH10927RootMappedSuperclass::class); |
| 37 | + |
| 38 | + self::assertNull($metadata->sequenceGeneratorDefinition); |
| 39 | + } |
| 40 | + |
| 41 | + public function testSequenceGeneratorDefinitionForEntityA(): void |
| 42 | + { |
| 43 | + $metadata = $this->_em->getClassMetadata(GH10927EntityA::class); |
| 44 | + |
| 45 | + self::assertSame('GH10927EntityA_id_seq', $metadata->sequenceGeneratorDefinition['sequenceName']); |
| 46 | + } |
| 47 | + |
| 48 | + public function testSequenceGeneratorDefinitionForInheritedMappedSuperclass(): void |
| 49 | + { |
| 50 | + $metadata = $this->_em->getClassMetadata(GH10927InheritedMappedSuperclass::class); |
| 51 | + |
| 52 | + self::assertSame('GH10927InheritedMappedSuperclass_id_seq', $metadata->sequenceGeneratorDefinition['sequenceName']); |
| 53 | + } |
| 54 | + |
| 55 | + public function testSequenceGeneratorDefinitionForEntityB(): void |
| 56 | + { |
| 57 | + $metadata = $this->_em->getClassMetadata(GH10927EntityB::class); |
| 58 | + |
| 59 | + self::assertSame('GH10927EntityB_id_seq', $metadata->sequenceGeneratorDefinition['sequenceName']); |
| 60 | + } |
| 61 | + |
| 62 | + public function testSequenceGeneratorDefinitionForEntityC(): void |
| 63 | + { |
| 64 | + $metadata = $this->_em->getClassMetadata(GH10927EntityC::class); |
| 65 | + |
| 66 | + self::assertSame('GH10927EntityB_id_seq', $metadata->sequenceGeneratorDefinition['sequenceName']); |
| 67 | + } |
| 68 | +} |
| 69 | + |
| 70 | +/** |
| 71 | + * @ORM\MappedSuperclass() |
| 72 | + */ |
| 73 | +class GH10927RootMappedSuperclass |
| 74 | +{ |
| 75 | +} |
| 76 | + |
| 77 | +/** |
| 78 | + * @ORM\Entity() |
| 79 | + */ |
| 80 | +class GH10927EntityA extends GH10927RootMappedSuperclass |
| 81 | +{ |
| 82 | + /** |
| 83 | + * @ORM\Id |
| 84 | + * @ORM\GeneratedValue(strategy="SEQUENCE") |
| 85 | + * @ORM\Column(type="integer") |
| 86 | + * |
| 87 | + * @var int|null |
| 88 | + */ |
| 89 | + private $id = null; |
| 90 | +} |
| 91 | + |
| 92 | +/** |
| 93 | + * @ORM\MappedSuperclass() |
| 94 | + */ |
| 95 | +class GH10927InheritedMappedSuperclass extends GH10927RootMappedSuperclass |
| 96 | +{ |
| 97 | + /** |
| 98 | + * @ORM\Id |
| 99 | + * @ORM\GeneratedValue(strategy="SEQUENCE") |
| 100 | + * @ORM\Column(type="integer") |
| 101 | + * |
| 102 | + * @var int|null |
| 103 | + */ |
| 104 | + private $id = null; |
| 105 | +} |
| 106 | + |
| 107 | +/** |
| 108 | + * @ORM\Entity() |
| 109 | + * @ORM\InheritanceType("JOINED") |
| 110 | + * @ORM\DiscriminatorColumn(name="discr", type="string") |
| 111 | + * @ORM\DiscriminatorMap({"B" = "GH10927EntityB", "C" = "GH10927EntityC"}) |
| 112 | + */ |
| 113 | +class GH10927EntityB extends GH10927InheritedMappedSuperclass |
| 114 | +{ |
| 115 | +} |
| 116 | + |
| 117 | +/** |
| 118 | + * @ORM\Entity() |
| 119 | + */ |
| 120 | +class GH10927EntityC extends GH10927EntityB |
| 121 | +{ |
| 122 | +} |
0 commit comments