|
32 | 32 | use Doctrine\ORM\Mapping\Driver\AttributeDriver;
|
33 | 33 | use Doctrine\ORM\Mapping\Driver\SimplifiedXmlDriver;
|
34 | 34 | use Doctrine\ORM\Mapping\Driver\SimplifiedYamlDriver;
|
| 35 | +use Doctrine\ORM\Mapping\Entity; |
35 | 36 | use Doctrine\Persistence\Mapping\Driver\MappingDriverChain;
|
| 37 | +use Fixtures\Bundles\AttributesBundle\Entity\TestCustomIdGeneratorEntity; |
36 | 38 | use InvalidArgumentException;
|
37 | 39 | use LogicException;
|
38 | 40 | use PHPUnit\Framework\TestCase;
|
@@ -1166,6 +1168,35 @@ public static function cacheConfigurationProvider(): array
|
1166 | 1168 | ];
|
1167 | 1169 | }
|
1168 | 1170 |
|
| 1171 | + public function testEntityAttributeExcludesFromContainer() |
| 1172 | + { |
| 1173 | + if (! interface_exists(Entity::class)) { |
| 1174 | + self::markTestSkipped('This test requires ORM'); |
| 1175 | + } |
| 1176 | + |
| 1177 | + $container = $this->getContainer(); |
| 1178 | + $extension = new DoctrineExtension(); |
| 1179 | + |
| 1180 | + $config = BundleConfigurationBuilder::createBuilder() |
| 1181 | + ->addBaseConnection() |
| 1182 | + ->addBaseEntityManager() |
| 1183 | + ->build(); |
| 1184 | + |
| 1185 | + $extension->load([$config], $container); |
| 1186 | + |
| 1187 | + $attributes = $container->getAutoconfiguredAttributes(); |
| 1188 | + $this->assertInstanceOf(Closure::class, $attributes[Entity::class]); |
| 1189 | + |
| 1190 | + $reflector = new ReflectionClass(TestCustomIdGeneratorEntity::class); |
| 1191 | + $definition = new ChildDefinition(''); |
| 1192 | + $attribute = $reflector->getAttributes(Entity::class)[0]->newInstance(); |
| 1193 | + |
| 1194 | + $attributes[Entity::class]($definition, $attribute); |
| 1195 | + |
| 1196 | + $this->assertSame([['source' => 'with #[Doctrine\ORM\Mapping\Entity] attribute']], $definition->getTag('container.excluded')); |
| 1197 | + $this->assertTrue($definition->isAbstract()); |
| 1198 | + } |
| 1199 | + |
1169 | 1200 | /** @requires PHP 8 */
|
1170 | 1201 | public function testAsEntityListenerAttribute()
|
1171 | 1202 | {
|
|
0 commit comments