|
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\Embeddable; |
| 36 | +use Doctrine\ORM\Mapping\Entity; |
| 37 | +use Doctrine\ORM\Mapping\MappedSuperclass; |
35 | 38 | use Doctrine\Persistence\Mapping\Driver\MappingDriverChain;
|
36 | 39 | use InvalidArgumentException;
|
37 | 40 | use LogicException;
|
@@ -1165,6 +1168,43 @@ public static function cacheConfigurationProvider(): array
|
1165 | 1168 | ];
|
1166 | 1169 | }
|
1167 | 1170 |
|
| 1171 | + /** @return array<array{0: class-string}> */ |
| 1172 | + public static function provideAttributeExcludedFromContainer(): array |
| 1173 | + { |
| 1174 | + return [ |
| 1175 | + 'Embeddable' => [Embeddable::class], |
| 1176 | + 'Entity' => [Entity::class], |
| 1177 | + 'MappedSuperclass' => [MappedSuperclass::class], |
| 1178 | + ]; |
| 1179 | + } |
| 1180 | + |
| 1181 | + /** @dataProvider provideAttributeExcludedFromContainer */ |
| 1182 | + public function testEntityAttributeExcludesFromContainer(string $class) |
| 1183 | + { |
| 1184 | + if (! interface_exists(EntityManagerInterface::class)) { |
| 1185 | + self::markTestSkipped('This test requires ORM'); |
| 1186 | + } |
| 1187 | + |
| 1188 | + $container = $this->getContainer(); |
| 1189 | + $extension = new DoctrineExtension(); |
| 1190 | + |
| 1191 | + $config = BundleConfigurationBuilder::createBuilder() |
| 1192 | + ->addBaseConnection() |
| 1193 | + ->addBaseEntityManager() |
| 1194 | + ->build(); |
| 1195 | + |
| 1196 | + $extension->load([$config], $container); |
| 1197 | + |
| 1198 | + $attributes = $container->getAutoconfiguredAttributes(); |
| 1199 | + $this->assertInstanceOf(Closure::class, $attributes[$class]); |
| 1200 | + |
| 1201 | + $definition = new ChildDefinition(''); |
| 1202 | + $attributes[$class]($definition); |
| 1203 | + |
| 1204 | + $this->assertSame([['source' => sprintf('with #[%s] attribute', $class)]], $definition->getTag('container.excluded')); |
| 1205 | + $this->assertTrue($definition->isAbstract()); |
| 1206 | + } |
| 1207 | + |
1168 | 1208 | public function testAsEntityListenerAttribute()
|
1169 | 1209 | {
|
1170 | 1210 | if (! interface_exists(EntityManagerInterface::class)) {
|
|
0 commit comments