From 89c91f6ee568a1ab017dbdf4836d8dd6e5df287a Mon Sep 17 00:00:00 2001 From: RahatHameed Date: Thu, 4 Jul 2024 18:52:46 +0200 Subject: [PATCH] OXDEV-8215 Improved unit test coverage --- .../Shared/Service/NamespaceMapperTest.php | 52 +++++++++++++++++++ .../Shared/Service/PermissionProviderTest.php | 30 +++++++++++ 2 files changed, 82 insertions(+) create mode 100644 tests/Unit/Shared/Service/NamespaceMapperTest.php create mode 100644 tests/Unit/Shared/Service/PermissionProviderTest.php diff --git a/tests/Unit/Shared/Service/NamespaceMapperTest.php b/tests/Unit/Shared/Service/NamespaceMapperTest.php new file mode 100644 index 0000000..07baf49 --- /dev/null +++ b/tests/Unit/Shared/Service/NamespaceMapperTest.php @@ -0,0 +1,52 @@ + self::PATH_TO_MAPPER . '/../../Module/Controller/', + self::NAMESPACE_PREFIX . '\\Shop\\Controller' => self::PATH_TO_MAPPER . '/../../Shop/Controller/', + self::NAMESPACE_PREFIX . '\\Theme\\Controller' => self::PATH_TO_MAPPER . '/../../Theme/Controller/', + ]; + + $sut = $this->getSut(); + $actualMapping = $sut->getControllerNamespaceMapping(); + + $this->assertSame($expectedMapping, $actualMapping); + } + + public function testGetTypeNamespaceMapping(): void + { + $expectedMapping = [ + self::NAMESPACE_PREFIX . '\\Shared\\DataType' => self::PATH_TO_MAPPER . '/../../Shared/DataType/', + self::NAMESPACE_PREFIX . '\\Module\\DataType' => self::PATH_TO_MAPPER . '/../../Module/DataType/', + ]; + + $sut = $this->getSut(); + $actualMapping = $sut->getTypeNamespaceMapping(); + + $this->assertSame($expectedMapping, $actualMapping); + } + + private function getSut(): NamespaceMapper + { + return new NamespaceMapper(); + } +} diff --git a/tests/Unit/Shared/Service/PermissionProviderTest.php b/tests/Unit/Shared/Service/PermissionProviderTest.php new file mode 100644 index 0000000..cb3962c --- /dev/null +++ b/tests/Unit/Shared/Service/PermissionProviderTest.php @@ -0,0 +1,30 @@ + [ + 'CHANGE_CONFIGURATION' + ], + ]; + + $permissionProvider = new PermissionProvider(); + $actualPermissions = $permissionProvider->getPermissions(); + + $this->assertSame($expectedPermissions, $actualPermissions); + } +}