diff --git a/tests/Assets/CustomClassMetadataFactory.php b/tests/Assets/CustomClassMetadataFactory.php new file mode 100644 index 0000000..40274a5 --- /dev/null +++ b/tests/Assets/CustomClassMetadataFactory.php @@ -0,0 +1,17 @@ + getAllMetadata() + * @method ClassMetadata[] getLoadedMetadata() + * @method ClassMetadata getMetadataFor($className) + */ +abstract class CustomClassMetadataFactory implements ClassMetadataFactoryInterface +{ +} diff --git a/tests/Assets/DefaultDocumentRepository.php b/tests/Assets/CustomDocumentRepository.php similarity index 79% rename from tests/Assets/DefaultDocumentRepository.php rename to tests/Assets/CustomDocumentRepository.php index bd838b1..ccbf09a 100644 --- a/tests/Assets/DefaultDocumentRepository.php +++ b/tests/Assets/CustomDocumentRepository.php @@ -6,7 +6,7 @@ use Doctrine\ODM\MongoDB\Repository\DocumentRepository; -class DefaultDocumentRepository extends DocumentRepository +class CustomDocumentRepository extends DocumentRepository { public function isCustomDefaultDocumentRepository(): bool { diff --git a/tests/Doctrine/ConfigurationFactoryTest.php b/tests/Doctrine/ConfigurationFactoryTest.php index 92eb731..4182688 100644 --- a/tests/Doctrine/ConfigurationFactoryTest.php +++ b/tests/Doctrine/ConfigurationFactoryTest.php @@ -14,9 +14,10 @@ use Doctrine\Persistence\Mapping\Driver\MappingDriver; use DoctrineMongoODMModule\Service\ConfigurationFactory; use DoctrineMongoODMModuleTest\AbstractTest; +use DoctrineMongoODMModuleTest\Assets\CustomClassMetadataFactory; +use DoctrineMongoODMModuleTest\Assets\CustomDocumentRepository; use DoctrineMongoODMModuleTest\Assets\CustomRepositoryFactory; use DoctrineMongoODMModuleTest\Assets\CustomType; -use DoctrineMongoODMModuleTest\Assets\DefaultDocumentRepository as CustomDocumentRepository; use Laminas\ServiceManager\ServiceManager; use function assert; @@ -84,7 +85,7 @@ public function testCreation(): void 'types' => [ $typeName = 'foo_type' => $typeClassName = CustomType::class, ], - 'classMetadataFactoryName' => 'stdClass', + 'classMetadataFactoryName' => CustomClassMetadataFactory::class, 'repositoryFactory' => CustomRepositoryFactory::class, 'default_document_repository_class_name' => CustomDocumentRepository::class, ], @@ -118,8 +119,8 @@ public function testCreation(): void $this->assertSame($persistentCollectionGenerator, $config->getPersistentCollectionGenerator()); $this->assertInstanceOf($typeClassName, Type::getType($typeName)); + $this->assertSame(CustomClassMetadataFactory::class, $config->getClassMetadataFactoryName()); $this->assertSame($repositoryFactory, $config->getRepositoryFactory()); - $this->assertSame(CustomDocumentRepository::class, $config->getDefaultDocumentRepositoryClassName()); } } diff --git a/tests/Doctrine/CustomDefaultRepositoryTest.php b/tests/Doctrine/CustomDefaultRepositoryTest.php index ebace8d..5ab6e1d 100644 --- a/tests/Doctrine/CustomDefaultRepositoryTest.php +++ b/tests/Doctrine/CustomDefaultRepositoryTest.php @@ -5,7 +5,7 @@ namespace DoctrineMongoODMModuleTest\Doctrine; use DoctrineMongoODMModuleTest\AbstractTest; -use DoctrineMongoODMModuleTest\Assets\DefaultDocumentRepository; +use DoctrineMongoODMModuleTest\Assets\CustomDocumentRepository; use DoctrineMongoODMModuleTest\Assets\Document\Simple; use function assert; @@ -18,8 +18,8 @@ public function testCustomDefaultRepository(): void $repository = $documentManager->getRepository(Simple::class); - $this->assertInstanceOf(DefaultDocumentRepository::class, $repository); - assert($repository instanceof DefaultDocumentRepository); + $this->assertInstanceOf(CustomDocumentRepository::class, $repository); + assert($repository instanceof CustomDocumentRepository); $this->assertTrue($repository->isCustomDefaultDocumentRepository()); } } diff --git a/tests/testing.config.php b/tests/testing.config.php index 7ce89ff..c276c19 100644 --- a/tests/testing.config.php +++ b/tests/testing.config.php @@ -13,7 +13,7 @@ 'configuration' => [ 'odm_default' => [ 'default_db' => 'doctrineMongoODMModuleTest', - 'default_document_repository_class_name' => Assets\DefaultDocumentRepository::class, + 'default_document_repository_class_name' => Assets\CustomDocumentRepository::class, ], ], 'connection' => [