1919use Doctrine \ODM \MongoDB \Configuration ;
2020use Doctrine \ODM \MongoDB \DocumentManager ;
2121use Doctrine \ODM \MongoDB \Mapping \Annotations ;
22+ use Doctrine \ODM \MongoDB \Mapping \Attribute ;
2223use InvalidArgumentException ;
2324use MongoDB \Client ;
2425use PHPUnit \Framework \Attributes \DataProvider ;
2526use PHPUnit \Framework \TestCase ;
2627use ProxyManager \Proxy \GhostObjectInterface ;
28+ use ReflectionClass ;
2729use stdClass ;
2830use Symfony \Component \DependencyInjection \Alias ;
2931use Symfony \Component \DependencyInjection \ChildDefinition ;
3739
3840use function array_diff_key ;
3941use function array_merge ;
42+ use function class_exists ;
4043use function interface_exists ;
4144use function is_dir ;
4245use function method_exists ;
@@ -134,18 +137,28 @@ public function testAsDocumentListenerAttribute(): void
134137 public static function provideAttributeExcludedFromContainer (): array
135138 {
136139 return [
137- 'Document ' => [Annotations \Document::class],
138- 'EmbeddedDocument ' => [Annotations \EmbeddedDocument::class],
139- 'MappedSuperclass ' => [Annotations \MappedSuperclass::class],
140- 'View ' => [Annotations \View::class],
141- 'QueryResultDocument ' => [Annotations \QueryResultDocument::class],
142- 'File ' => [Annotations \File::class],
140+ 'Annotations\Document ' => [Annotations \Document::class],
141+ 'Annotations\EmbeddedDocument ' => [Annotations \EmbeddedDocument::class],
142+ 'Annotations\MappedSuperclass ' => [Annotations \MappedSuperclass::class],
143+ 'Annotations\View ' => [Annotations \View::class],
144+ 'Annotations\QueryResultDocument ' => [Annotations \QueryResultDocument::class],
145+ 'Annotations\File ' => [Annotations \File::class],
146+ 'Attribute\Document ' => [Attribute \Document::class],
147+ 'Attribute\EmbeddedDocument ' => [Attribute \EmbeddedDocument::class],
148+ 'Attribute\MappedSuperclass ' => [Attribute \MappedSuperclass::class],
149+ 'Attribute\View ' => [Attribute \View::class],
150+ 'Attribute\QueryResultDocument ' => [Attribute \QueryResultDocument::class],
151+ 'Attribute\File ' => [Attribute \File::class],
143152 ];
144153 }
145154
146155 #[DataProvider('provideAttributeExcludedFromContainer ' )]
147156 public function testDocumentAttributeExcludesFromContainer (string $ class ): void
148157 {
158+ if (! class_exists ($ class )) {
159+ $ this ->markTestSkipped (sprintf ('Class %s does not exist. ' , $ class ));
160+ }
161+
149162 $ container = $ this ->getContainer ();
150163 $ extension = new DoctrineMongoDBExtension ();
151164 $ extension ->load ($ this ->buildConfiguration (), $ container );
@@ -163,7 +176,8 @@ public function testDocumentAttributeExcludesFromContainer(string $class): void
163176 $ this ->assertInstanceOf (Closure::class, $ autoconfigurator );
164177
165178 $ definition = new ChildDefinition ('' );
166- $ autoconfigurator ($ definition );
179+ $ attribute = (new ReflectionClass ($ class ))->newInstanceWithoutConstructor ();
180+ $ autoconfigurator ($ definition , $ attribute );
167181
168182 $ this ->assertSame ([['source ' => sprintf ('with #[%s] attribute ' , $ class )]], $ definition ->getTag ('container.excluded ' ));
169183 }
0 commit comments