Skip to content

Commit

Permalink
OXDEV-8216: Move module's Infrastructure method to Service
Browse files Browse the repository at this point in the history
  • Loading branch information
MarcelOxid committed Aug 12, 2024
1 parent d7d3efd commit 5b02a65
Show file tree
Hide file tree
Showing 9 changed files with 22 additions and 133 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
class ModuleSwitchController
{
public function __construct(
private readonly ModuleSwitchServiceInterface $moduleSwitchService
private readonly ModuleActivationServiceInterface $moduleService
) {
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
30 changes: 0 additions & 30 deletions src/Module/Service/ModuleSwitchService.php

This file was deleted.

14 changes: 0 additions & 14 deletions src/Module/Service/ModuleSwitchServiceInterface.php

This file was deleted.

7 changes: 2 additions & 5 deletions src/Module/services.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,5 @@ services:
OxidEsales\GraphQL\ConfigurationAccess\Module\Service\ModuleSettingServiceInterface:
class: OxidEsales\GraphQL\ConfigurationAccess\Module\Service\ModuleSettingService

OxidEsales\GraphQL\ConfigurationAccess\Module\Infrastructure\ModuleSwitchInfrastructureInterface:
class: OxidEsales\GraphQL\ConfigurationAccess\Module\Infrastructure\ModuleSwitchInfrastructure

OxidEsales\GraphQL\ConfigurationAccess\Module\Service\ModuleSwitchServiceInterface:
class: OxidEsales\GraphQL\ConfigurationAccess\Module\Service\ModuleSwitchService
OxidEsales\GraphQL\ConfigurationAccess\Module\Service\ModuleActivationServiceInterface:
class: OxidEsales\GraphQL\ConfigurationAccess\Module\Service\ModuleActivationService
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
namespace OxidEsales\GraphQL\ConfigurationAccess\Tests\Unit\Module\Controller;

use OxidEsales\GraphQL\ConfigurationAccess\Module\Controller\ModuleSwitchController;
use OxidEsales\GraphQL\ConfigurationAccess\Module\Service\ModuleSwitchServiceInterface;
use OxidEsales\GraphQL\ConfigurationAccess\Module\Service\ModuleActivationServiceInterface;
use PHPUnit\Framework\TestCase;

/**
Expand All @@ -22,13 +22,13 @@ public function testActivateModule(): void
{
$moduleId = 'testModuleId';

$moduleSwitchServiceMock = $this->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);
Expand All @@ -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
);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
63 changes: 0 additions & 63 deletions tests/Unit/Module/Service/ModuleSwitchServiceTest.php

This file was deleted.

0 comments on commit 5b02a65

Please sign in to comment.