Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merge release 5.0.2 into 5.1.x #284

Merged
merged 4 commits into from
Jan 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
{
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

use Doctrine\ODM\MongoDB\Repository\DocumentRepository;

class DefaultDocumentRepository extends DocumentRepository
class CustomDocumentRepository extends DocumentRepository
{
public function isCustomDefaultDocumentRepository(): bool
{
Expand Down
7 changes: 4 additions & 3 deletions tests/Doctrine/ConfigurationFactoryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
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,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());
}
}
6 changes: 3 additions & 3 deletions tests/Doctrine/CustomDefaultRepositoryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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());
}
}
2 changes: 1 addition & 1 deletion tests/testing.config.php
Original file line number Diff line number Diff line change
Expand Up @@ -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' => [
Expand Down
Loading