From 11f0a0450169b255d0021bfe0f0e7a68843a3fcc Mon Sep 17 00:00:00 2001 From: Maxime Steinhausser Date: Tue, 3 May 2022 16:26:23 +0200 Subject: [PATCH] Add missing ODM extensions test + XSD types --- .../Bundle/config/schema/elao_enum.xsd | 20 +++++++++++++++++++ .../xml/doctrine_mongodb_types.xml | 15 ++++++++++++++ .../yaml/doctrine_mongodb_types.yaml | 6 ++++++ .../ElaoEnumExtensionTest.php | 20 +++++++++++++++++++ 4 files changed, 61 insertions(+) create mode 100644 tests/Fixtures/Bridge/Symfony/Bundle/DependencyInjection/ElaoEnumExtension/xml/doctrine_mongodb_types.xml create mode 100644 tests/Fixtures/Bridge/Symfony/Bundle/DependencyInjection/ElaoEnumExtension/yaml/doctrine_mongodb_types.yaml diff --git a/src/Bridge/Symfony/Bundle/config/schema/elao_enum.xsd b/src/Bridge/Symfony/Bundle/config/schema/elao_enum.xsd index 3955a2e..60d70fb 100644 --- a/src/Bridge/Symfony/Bundle/config/schema/elao_enum.xsd +++ b/src/Bridge/Symfony/Bundle/config/schema/elao_enum.xsd @@ -10,6 +10,7 @@ + @@ -34,4 +35,23 @@ + + + + + + + + + + + + + + + + + + + diff --git a/tests/Fixtures/Bridge/Symfony/Bundle/DependencyInjection/ElaoEnumExtension/xml/doctrine_mongodb_types.xml b/tests/Fixtures/Bridge/Symfony/Bundle/DependencyInjection/ElaoEnumExtension/xml/doctrine_mongodb_types.xml new file mode 100644 index 0000000..6f4432a --- /dev/null +++ b/tests/Fixtures/Bridge/Symfony/Bundle/DependencyInjection/ElaoEnumExtension/xml/doctrine_mongodb_types.xml @@ -0,0 +1,15 @@ + + + + + + + + + + + + diff --git a/tests/Fixtures/Bridge/Symfony/Bundle/DependencyInjection/ElaoEnumExtension/yaml/doctrine_mongodb_types.yaml b/tests/Fixtures/Bridge/Symfony/Bundle/DependencyInjection/ElaoEnumExtension/yaml/doctrine_mongodb_types.yaml new file mode 100644 index 0000000..874b907 --- /dev/null +++ b/tests/Fixtures/Bridge/Symfony/Bundle/DependencyInjection/ElaoEnumExtension/yaml/doctrine_mongodb_types.yaml @@ -0,0 +1,6 @@ +elao_enum: + doctrine_mongodb: + types: + suit: Elao\Enum\Tests\Fixtures\Enum\Suit + request_status: { class: Elao\Enum\Tests\Fixtures\Enum\RequestStatus, type: single } + permissions: { class: Elao\Enum\Tests\Fixtures\Enum\Permissions, type: collection } diff --git a/tests/Unit/Bridge/Symfony/Bundle/DependencyInjection/ElaoEnumExtensionTest.php b/tests/Unit/Bridge/Symfony/Bundle/DependencyInjection/ElaoEnumExtensionTest.php index e4cec9f..ecb383d 100644 --- a/tests/Unit/Bridge/Symfony/Bundle/DependencyInjection/ElaoEnumExtensionTest.php +++ b/tests/Unit/Bridge/Symfony/Bundle/DependencyInjection/ElaoEnumExtensionTest.php @@ -13,6 +13,7 @@ namespace Elao\Enum\Tests\Unit\Bridge\Symfony\Bundle\DependencyInjection; use Doctrine\Bundle\DoctrineBundle\DoctrineBundle; +use Doctrine\Bundle\MongoDBBundle\DoctrineMongoDBBundle; use Elao\Enum\Bridge\Symfony\Bundle\DependencyInjection\ElaoEnumExtension; use Elao\Enum\Tests\Fixtures\Enum\Permissions; use Elao\Enum\Tests\Fixtures\Enum\RequestStatus; @@ -78,6 +79,24 @@ public function testDoctrineTypesArePrepended(): void ], $container->getExtensionConfig('doctrine')); } + public function testDoctrineOdmTypesArePrepended(): void + { + $container = $this->createContainerFromFile('doctrine_mongodb_types', false); + /** @var ElaoEnumExtension $ext */ + $ext = $container->getExtension('elao_enum'); + $ext->prepend($container); + + self::assertEquals([ + [ + 'types' => [ + 'suit' => 'ELAO_ENUM_DT_ODM\\Elao\\Enum\\Tests\\Fixtures\\Enum\\SuitType', + 'request_status' => 'ELAO_ENUM_DT_ODM\\Elao\\Enum\\Tests\\Fixtures\\Enum\\RequestStatusType', + 'permissions' => 'ELAO_ENUM_DT_ODM\\Elao\\Enum\\Tests\\Fixtures\\Enum\\PermissionsCollectionType', + ], + ], + ], $container->getExtensionConfig('doctrine_mongodb')); + } + protected function createContainerFromFile(string $file, bool $compile = true): ContainerBuilder { $container = $this->createContainer(); @@ -102,6 +121,7 @@ protected function createContainer(): ContainerBuilder return new ContainerBuilder(new EnvPlaceholderParameterBag([ 'kernel.bundles' => [ 'DoctrineBundle' => DoctrineBundle::class, + 'DoctrineMongoDBBundle' => DoctrineMongoDBBundle::class, ], 'kernel.cache_dir' => self::FIXTURES_PATH . '/cache_dir', ]));