From 20b71791e0e8cfea31b85dcf9ca78832f89fa69e Mon Sep 17 00:00:00 2001 From: marcelmanzel Date: Wed, 14 Aug 2024 17:07:00 +0200 Subject: [PATCH] OXDEV-8489: Rename identifier to themeId for switchTheme-mutation --- src/Theme/Controller/ThemeSwitchController.php | 6 +++--- .../Infrastructure/ThemeSwitchInfrastructure.php | 4 ++-- .../ThemeSwitchInfrastructureInterface.php | 2 +- src/Theme/Service/ThemeSwitchService.php | 4 ++-- src/Theme/Service/ThemeSwitchServiceInterface.php | 2 +- .../Codeception/Acceptance/Theme/ThemeSwitchCest.php | 2 +- .../Theme/Controller/ThemeSwitchControllerTest.php | 10 +++++----- .../Infrastructure/ThemeSwitchInfrastructureTest.php | 12 ++++++------ tests/Unit/Theme/Service/ThemeSwitchServiceTest.php | 6 +++--- 9 files changed, 24 insertions(+), 24 deletions(-) diff --git a/src/Theme/Controller/ThemeSwitchController.php b/src/Theme/Controller/ThemeSwitchController.php index 8b6d9d4..d00a5f7 100644 --- a/src/Theme/Controller/ThemeSwitchController.php +++ b/src/Theme/Controller/ThemeSwitchController.php @@ -23,14 +23,14 @@ public function __construct( /** * Mutation of Configuration Access Module - * @param string $identifier + * @param string $themeId * @return bool */ #[Mutation] #[Logged] #[Right('CHANGE_CONFIGURATION')] - public function switchTheme(string $identifier): bool + public function switchTheme(string $themeId): bool { - return $this->themeSwitchService->switchTheme($identifier); + return $this->themeSwitchService->switchTheme($themeId); } } diff --git a/src/Theme/Infrastructure/ThemeSwitchInfrastructure.php b/src/Theme/Infrastructure/ThemeSwitchInfrastructure.php index 1386c00..87efcc4 100644 --- a/src/Theme/Infrastructure/ThemeSwitchInfrastructure.php +++ b/src/Theme/Infrastructure/ThemeSwitchInfrastructure.php @@ -21,11 +21,11 @@ public function __construct( ) { } - public function switchTheme(string $identifier): bool + public function switchTheme(string $themeId): bool { try { $coreThemeService = $this->coreThemeFactory->create(); - if (!$coreThemeService->load($identifier)) { + if (!$coreThemeService->load($themeId)) { throw new ThemeActivationException(self::THEME_NOT_EXIST); } $coreThemeService->activate(); diff --git a/src/Theme/Infrastructure/ThemeSwitchInfrastructureInterface.php b/src/Theme/Infrastructure/ThemeSwitchInfrastructureInterface.php index f27daa0..6f782ed 100644 --- a/src/Theme/Infrastructure/ThemeSwitchInfrastructureInterface.php +++ b/src/Theme/Infrastructure/ThemeSwitchInfrastructureInterface.php @@ -14,5 +14,5 @@ interface ThemeSwitchInfrastructureInterface /** *@throws ThemeActivationException */ - public function switchTheme(string $identifier): bool; + public function switchTheme(string $themeId): bool; } diff --git a/src/Theme/Service/ThemeSwitchService.php b/src/Theme/Service/ThemeSwitchService.php index da6a065..ba742b1 100644 --- a/src/Theme/Service/ThemeSwitchService.php +++ b/src/Theme/Service/ThemeSwitchService.php @@ -17,8 +17,8 @@ public function __construct( private readonly ThemeSwitchInfrastructureInterface $themeSwitchInfrastructure ) { } - public function switchTheme(string $identifier): bool + public function switchTheme(string $themeId): bool { - return $this->themeSwitchInfrastructure->switchTheme(identifier: $identifier); + return $this->themeSwitchInfrastructure->switchTheme(themeId: $themeId); } } diff --git a/src/Theme/Service/ThemeSwitchServiceInterface.php b/src/Theme/Service/ThemeSwitchServiceInterface.php index 041a7ca..3cfb462 100644 --- a/src/Theme/Service/ThemeSwitchServiceInterface.php +++ b/src/Theme/Service/ThemeSwitchServiceInterface.php @@ -9,5 +9,5 @@ interface ThemeSwitchServiceInterface { - public function switchTheme(string $identifier): bool; + public function switchTheme(string $themeId): bool; } diff --git a/tests/Codeception/Acceptance/Theme/ThemeSwitchCest.php b/tests/Codeception/Acceptance/Theme/ThemeSwitchCest.php index 89b3c10..b15f3d3 100644 --- a/tests/Codeception/Acceptance/Theme/ThemeSwitchCest.php +++ b/tests/Codeception/Acceptance/Theme/ThemeSwitchCest.php @@ -34,7 +34,7 @@ private function runThemeSwitchMutation(AcceptanceTester $I): array $I->sendGQLQuery( 'mutation switchThemeCest{ - switchTheme(identifier: "' . $themeId . '") + switchTheme(themeId: "' . $themeId . '") }' ); diff --git a/tests/Unit/Theme/Controller/ThemeSwitchControllerTest.php b/tests/Unit/Theme/Controller/ThemeSwitchControllerTest.php index eb6eb9f..9bc7aee 100644 --- a/tests/Unit/Theme/Controller/ThemeSwitchControllerTest.php +++ b/tests/Unit/Theme/Controller/ThemeSwitchControllerTest.php @@ -20,17 +20,17 @@ class ThemeSwitchControllerTest extends TestCase { /** @dataProvider switchThemeProvider */ public function testSwitchTheme( - string $identifier, + string $themeId, bool $expectedResult ): void { $themeSwitchServiceMock = $this->createMock(ThemeSwitchServiceInterface::class); $themeSwitchServiceMock ->method('switchTheme') - ->with($identifier) + ->with($themeId) ->willReturn($expectedResult); $themeSwitchController = new ThemeSwitchController($themeSwitchServiceMock); - $response = $themeSwitchController->switchTheme($identifier); + $response = $themeSwitchController->switchTheme($themeId); $this->assertSame($expectedResult, $response); } @@ -38,12 +38,12 @@ public function testSwitchTheme( public static function switchThemeProvider(): \Generator { yield 'test switch theme successful case' => [ - 'identifier' => 'validThemeId', + 'themeId' => 'validThemeId', 'expectedResult' => true ]; yield 'test switch theme failure case' => [ - 'identifier' => 'invalidThemeId', + 'themeId' => 'invalidThemeId', 'expectedResult' => false ]; } diff --git a/tests/Unit/Theme/Infrastructure/ThemeSwitchInfrastructureTest.php b/tests/Unit/Theme/Infrastructure/ThemeSwitchInfrastructureTest.php index 2714167..467fbf7 100644 --- a/tests/Unit/Theme/Infrastructure/ThemeSwitchInfrastructureTest.php +++ b/tests/Unit/Theme/Infrastructure/ThemeSwitchInfrastructureTest.php @@ -25,23 +25,23 @@ class ThemeSwitchInfrastructureTest extends TestCase private const THEME_NOT_EXIST = "The specified theme doesn't exist."; public function testSwitchTheme(): void { - $identifier = 'apex'; + $themeId = 'apex'; $coreThemeMock = $this->createMock(Theme::class); - $coreThemeMock->expects($this->once())->method('load')->with($identifier)->willReturn(true); + $coreThemeMock->expects($this->once())->method('load')->with($themeId)->willReturn(true); $coreThemeMock->expects($this->once())->method('activate'); $coreThemeFactoryMock = $this->getCoreThemeFactoryMock(coreThemeMock: $coreThemeMock); $sut = $this->getSut(coreThemeFactory: $coreThemeFactoryMock); - $serviceResponse = $sut->switchTheme($identifier); + $serviceResponse = $sut->switchTheme($themeId); $this->assertTrue($serviceResponse); } public function testThemeNotActivatedException(): void { - $identifier = 'apex'; + $themeId = 'apex'; $coreThemeMock = $this->createMock(Theme::class); - $coreThemeMock->expects($this->once())->method('load')->with($identifier)->willReturn(true); + $coreThemeMock->expects($this->once())->method('load')->with($themeId)->willReturn(true); $coreThemeMock->expects($this->once())->method('activate') ->will($this->throwException( new StandardException(self::THEME_NOT_ACTIVATED) @@ -52,7 +52,7 @@ public function testThemeNotActivatedException(): void $this->expectException(ThemeActivationException::class); $this->expectExceptionMessage(self::THEME_NOT_ACTIVATED); - $sut->switchTheme($identifier); + $sut->switchTheme($themeId); } public function testThemeNotFoundException(): void diff --git a/tests/Unit/Theme/Service/ThemeSwitchServiceTest.php b/tests/Unit/Theme/Service/ThemeSwitchServiceTest.php index 02fcab2..70cb8d0 100644 --- a/tests/Unit/Theme/Service/ThemeSwitchServiceTest.php +++ b/tests/Unit/Theme/Service/ThemeSwitchServiceTest.php @@ -22,15 +22,15 @@ class ThemeSwitchServiceTest extends TestCase public function testSwitchTheme( bool $expectedResult ): void { - $identifier = uniqid(); + $themeId = uniqid(); $themeSwitchInfrastructureMock = $this->createMock(ThemeSwitchInfrastructureInterface::class); $themeSwitchInfrastructureMock ->method('switchTheme') - ->with($identifier) + ->with($themeId) ->willReturn($expectedResult); $themeSwitchInfrastructure = new ThemeSwitchService($themeSwitchInfrastructureMock); - $response = $themeSwitchInfrastructure->switchTheme($identifier); + $response = $themeSwitchInfrastructure->switchTheme($themeId); $this->assertSame($expectedResult, $response); }