Skip to content

Commit

Permalink
added mock for class metadata
Browse files Browse the repository at this point in the history
  • Loading branch information
driehle committed Jan 21, 2024
1 parent 247f581 commit 57454cf
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 2 deletions.
17 changes: 17 additions & 0 deletions tests/Assets/CustomClassMetadataFactory.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?php

declare(strict_types=1);

namespace DoctrineMongoODMModuleTest\Assets;

use Doctrine\ODM\MongoDB\Mapping\ClassMetadataFactoryInterface;
use Doctrine\Persistence\Mapping\ClassMetadata;

/**
* @method list<ClassMetadata> getAllMetadata()
* @method ClassMetadata[] getLoadedMetadata()
* @method ClassMetadata getMetadataFor($className)
*/
abstract class CustomClassMetadataFactory implements ClassMetadataFactoryInterface
{
}
5 changes: 3 additions & 2 deletions tests/Doctrine/ConfigurationFactoryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
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;
Expand Down Expand Up @@ -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,
],
Expand Down Expand Up @@ -118,7 +119,7 @@ public function testCreation(): void
$this->assertSame($persistentCollectionGenerator, $config->getPersistentCollectionGenerator());

$this->assertInstanceOf($typeClassName, Type::getType($typeName));
$this->assertSame('stdClass', $config->getClassMetadataFactoryName());
$this->assertSame(CustomClassMetadataFactory::class, $config->getClassMetadataFactoryName());
$this->assertSame($repositoryFactory, $config->getRepositoryFactory());
$this->assertSame(CustomDocumentRepository::class, $config->getDefaultDocumentRepositoryClassName());
}
Expand Down

0 comments on commit 57454cf

Please sign in to comment.