diff --git a/src/Module/Controller/ModuleSwitchController.php b/src/Module/Controller/ModuleActivationController.php similarity index 94% rename from src/Module/Controller/ModuleSwitchController.php rename to src/Module/Controller/ModuleActivationController.php index 91cafc6..968e3f9 100644 --- a/src/Module/Controller/ModuleSwitchController.php +++ b/src/Module/Controller/ModuleActivationController.php @@ -17,7 +17,7 @@ class ModuleSwitchController { public function __construct( - private readonly ModuleSwitchServiceInterface $moduleSwitchService + private readonly ModuleActivationServiceInterface $moduleService ) { } diff --git a/src/Module/Infrastructure/ModuleSwitchInfrastructure.php b/src/Module/Service/ModuleActivationService.php similarity index 90% rename from src/Module/Infrastructure/ModuleSwitchInfrastructure.php rename to src/Module/Service/ModuleActivationService.php index 5d55530..70c2246 100644 --- a/src/Module/Infrastructure/ModuleSwitchInfrastructure.php +++ b/src/Module/Service/ModuleActivationService.php @@ -7,14 +7,14 @@ declare(strict_types=1); -namespace OxidEsales\GraphQL\ConfigurationAccess\Module\Infrastructure; +namespace OxidEsales\GraphQL\ConfigurationAccess\Module\Service; use OxidEsales\EshopCommunity\Internal\Framework\Module\Setup\Bridge\ModuleActivationBridgeInterface; use OxidEsales\EshopCommunity\Internal\Transition\Utility\ContextInterface; use OxidEsales\GraphQL\ConfigurationAccess\Module\Exception\ModuleActivationException; use OxidEsales\GraphQL\ConfigurationAccess\Module\Exception\ModuleDeactivationException; -class ModuleSwitchInfrastructure implements ModuleSwitchInfrastructureInterface +class ModuleActivationService implements ModuleActivationServiceInterface { public function __construct( private readonly ContextInterface $context, diff --git a/src/Module/Infrastructure/ModuleSwitchInfrastructureInterface.php b/src/Module/Service/ModuleActivationServiceInterface.php similarity index 81% rename from src/Module/Infrastructure/ModuleSwitchInfrastructureInterface.php rename to src/Module/Service/ModuleActivationServiceInterface.php index 0558cbc..1181e9c 100644 --- a/src/Module/Infrastructure/ModuleSwitchInfrastructureInterface.php +++ b/src/Module/Service/ModuleActivationServiceInterface.php @@ -5,12 +5,12 @@ * See LICENSE file for license details. */ -namespace OxidEsales\GraphQL\ConfigurationAccess\Module\Infrastructure; +namespace OxidEsales\GraphQL\ConfigurationAccess\Module\Service; use OxidEsales\GraphQL\ConfigurationAccess\Module\Exception\ModuleActivationException; use OxidEsales\GraphQL\ConfigurationAccess\Module\Exception\ModuleDeactivationException; -interface ModuleSwitchInfrastructureInterface +interface ModuleActivationServiceInterface { /** * @throws ModuleActivationException diff --git a/src/Module/Service/ModuleSwitchService.php b/src/Module/Service/ModuleSwitchService.php deleted file mode 100644 index 75ca5c0..0000000 --- a/src/Module/Service/ModuleSwitchService.php +++ /dev/null @@ -1,30 +0,0 @@ -moduleSwitchInfrastructure->activateModule(moduleId: $moduleId); - } - - public function deactivateModule(string $moduleId): bool - { - return $this->moduleSwitchInfrastructure->deactivateModule(moduleId: $moduleId); - } -} diff --git a/src/Module/Service/ModuleSwitchServiceInterface.php b/src/Module/Service/ModuleSwitchServiceInterface.php deleted file mode 100644 index 0178c57..0000000 --- a/src/Module/Service/ModuleSwitchServiceInterface.php +++ /dev/null @@ -1,14 +0,0 @@ -createMock(ModuleSwitchServiceInterface::class); - $moduleSwitchServiceMock + $moduleActivationServiceMock = $this->createMock(ModuleActivationServiceInterface::class); + $moduleActivationServiceMock ->method('activateModule') ->with($moduleId) ->willReturn(true); - $sut = $this->getSut(moduleSwitchService: $moduleSwitchServiceMock); + $sut = $this->getSut(moduleActivationService: $moduleActivationServiceMock); $result = $sut->activateModule($moduleId); $this->assertTrue($result); @@ -38,24 +38,23 @@ public function testDeactivateModule(): void { $moduleId = 'testModuleId'; - $moduleSwitchServiceMock = $this->createMock(ModuleSwitchServiceInterface::class); - $moduleSwitchServiceMock + $moduleActivationServiceMock = $this->createMock(ModuleActivationServiceInterface::class); + $moduleActivationServiceMock ->method('deactivateModule') ->with($moduleId) ->willReturn(true); - $sut = $this->getSut(moduleSwitchService: $moduleSwitchServiceMock); + $sut = $this->getSut(moduleActivationService: $moduleActivationServiceMock); $result = $sut->deactivateModule($moduleId); $this->assertTrue($result); } public function getSut( - ModuleSwitchServiceInterface $moduleSwitchService = null ): ModuleSwitchController { return new ModuleSwitchController( - moduleSwitchService: $moduleSwitchService - ?? $this->createStub(ModuleSwitchServiceInterface::class) + ModuleActivationServiceInterface $moduleActivationService = null + moduleService: $moduleActivationService ); } } diff --git a/tests/Unit/Module/Infrastructure/ModuleSwitchInfrastructureTest.php b/tests/Unit/Module/Service/ModuleActivationsServiceTest.php similarity index 90% rename from tests/Unit/Module/Infrastructure/ModuleSwitchInfrastructureTest.php rename to tests/Unit/Module/Service/ModuleActivationsServiceTest.php index d9b034b..541a079 100644 --- a/tests/Unit/Module/Infrastructure/ModuleSwitchInfrastructureTest.php +++ b/tests/Unit/Module/Service/ModuleActivationsServiceTest.php @@ -7,19 +7,19 @@ declare(strict_types=1); -namespace OxidEsales\GraphQL\ConfigurationAccess\Tests\Unit\Module\Infrastructure; +namespace OxidEsales\GraphQL\ConfigurationAccess\Tests\Unit\Module\Service; use OxidEsales\EshopCommunity\Internal\Transition\Utility\ContextInterface; -use OxidEsales\GraphQL\ConfigurationAccess\Module\Infrastructure\ModuleSwitchInfrastructure; use OxidEsales\EshopCommunity\Internal\Framework\Module\Setup\Bridge\ModuleActivationBridgeInterface; use OxidEsales\GraphQL\ConfigurationAccess\Module\Exception\ModuleActivationException; use OxidEsales\GraphQL\ConfigurationAccess\Module\Exception\ModuleDeactivationException; +use OxidEsales\GraphQL\ConfigurationAccess\Module\Service\ModuleActivationService; use OxidEsales\GraphQL\ConfigurationAccess\Tests\Unit\UnitTestCase; /** - * @covers \OxidEsales\GraphQL\ConfigurationAccess\Module\Infrastructure\ModuleSwitchInfrastructure + * @covers \OxidEsales\GraphQL\ConfigurationAccess\Module\Service\ModuleActivationService */ -class ModuleSwitchInfrastructureTest extends UnitTestCase +class ModuleActivationsServiceTest extends UnitTestCase { /** * @dataProvider activationDataProvider @@ -103,8 +103,8 @@ public static function exceptionDataProvider(): \Generator public function getSut( ContextInterface $context = null, ModuleActivationBridgeInterface $moduleActivationBridge = null - ): ModuleSwitchInfrastructure { - return new ModuleSwitchInfrastructure( + ): ModuleActivationService { + return new ModuleActivationService( context: $context ?? $this->createStub(ContextInterface::class), moduleActivationBridge: $moduleActivationBridge diff --git a/tests/Unit/Module/Service/ModuleSwitchServiceTest.php b/tests/Unit/Module/Service/ModuleSwitchServiceTest.php deleted file mode 100644 index 1a87b27..0000000 --- a/tests/Unit/Module/Service/ModuleSwitchServiceTest.php +++ /dev/null @@ -1,63 +0,0 @@ -createMock(ModuleSwitchInfrastructureInterface::class); - $moduleSwitchInfrastructureMock - ->method($method) - ->with($moduleId) - ->willReturn(true); - - $sut = $this->getSut(moduleSwitchInfrastructure: $moduleSwitchInfrastructureMock); - $actualResult = ($method == 'activateModule') - ? $sut->activateModule(moduleId: $moduleId) - : $sut->deactivateModule(moduleId: $moduleId); - - $this->assertTrue($actualResult); - } - - private function getSut( - ModuleSwitchInfrastructureInterface $moduleSwitchInfrastructure = null - ): ModuleSwitchService { - return new ModuleSwitchService( - moduleSwitchInfrastructure: $moduleSwitchInfrastructure - ?? $this->createStub(ModuleSwitchInfrastructureInterface::class) - ); - } - - public static function activationDataProvider(): \Generator - { - yield 'test activate module' => [ - 'method' => 'activateModule', - 'moduleId' => uniqid() - ]; - - yield 'test deactivate module' => [ - 'method' => 'deactivateModule', - 'moduleId' => uniqid() - ]; - } -}