Skip to content

Commit

Permalink
OXDEV-8214: Adjustments of tests and removal of Integrationtest for t…
Browse files Browse the repository at this point in the history
…heme switch
  • Loading branch information
MarcelOxid committed Aug 9, 2024
1 parent 2573276 commit b0b6bf1
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 56 deletions.
4 changes: 2 additions & 2 deletions tests/Codeception/Acceptance/NotAuthorizedAccessCest.php
Original file line number Diff line number Diff line change
Expand Up @@ -264,12 +264,12 @@ private function runSimplifiedAccessCheckMutation(
return $I->grabJsonResponseAsArray();
}

private function getLocationParameterString(string $location): ?string
private function getLocationParameterString(string $location): string
{
return match ($location) {
'module' => 'moduleId: "testModule"',
'theme' => 'themeId: "testTheme"',
default => null
default => ''
};
}

Expand Down
4 changes: 2 additions & 2 deletions tests/Codeception/Acceptance/Theme/ThemeSwitchCest.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public function testThemeSwitchAuthorized(AcceptanceTester $I): void

public function runThemeSwitchMutation(AcceptanceTester $I): array
{
$themeId = $this->getThemeId();
$themeId = $this->getCurrentThemeId();

$I->sendGQLQuery(
'mutation switchThemeCest{
Expand All @@ -43,7 +43,7 @@ public function runThemeSwitchMutation(AcceptanceTester $I): array
return $I->grabJsonResponseAsArray();
}

private function getThemeId(): string
private function getCurrentThemeId(): string
{
$shopAdapter = $this->get(ShopAdapterInterface::class);
return $shopAdapter->getActiveThemeId();
Expand Down
45 changes: 0 additions & 45 deletions tests/Integration/Infrastructure/ThemeSwitchInfrastructureTest.php

This file was deleted.

7 changes: 4 additions & 3 deletions tests/Unit/Theme/Exception/ThemeActivationExceptionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,18 +18,19 @@
*/
class ThemeActivationExceptionTest extends TestCase
{
private const THEME_NOT_ACTIVATED = "An error occurred while activating the theme.";
private const THEME_NOT_ACTIVATED_MESSAGE = "An error occurred while activating the theme.";

public function testThemeActivationExceptionDefaultMessage()
{
$exception = new ThemeActivationException();

$this->assertInstanceOf(ThemeActivationException::class, $exception);
$this->assertSame(self::THEME_NOT_ACTIVATED, $exception->getMessage());
$this->assertSame(self::THEME_NOT_ACTIVATED_MESSAGE, $exception->getMessage());
}

public function testThemeActivationExceptionWithMessage()
{
$message = 'This is just a message';
$message = uniqid();
$exception = new ThemeActivationException($message);

$this->assertInstanceOf(ThemeActivationException::class, $exception);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,22 +61,22 @@ public function testThemeNotFoundException(): void
$coreThemeMock->method('load')->willReturn(false);

$coreThemeFactoryMock = $this->getCoreThemeFactoryMock(coreThemeMock: $coreThemeMock);
$sut = $this->getSut($coreThemeFactoryMock);
$sut = $this->getSut(coreThemeFactory: $coreThemeFactoryMock);

$this->expectException(ThemeActivationException::class);
$this->expectExceptionMessage(self::THEME_NOT_EXIST);
$sut->switchTheme('invalidThemeId');
}

private function getSut(
CoreThemeFactoryInterface $coreThemeFactory = null,
CoreThemeFactoryInterface $coreThemeFactory,
): ThemeSwitchInfrastructure {
return new ThemeSwitchInfrastructure(
coreThemeFactory: $coreThemeFactory ?? $this->createStub(ThemeSwitchInfrastructure::class),
coreThemeFactory: $coreThemeFactory,
);
}

private function getCoreThemeFactoryMock($coreThemeMock): CoreThemeFactoryInterface
private function getCoreThemeFactoryMock(Theme $coreThemeMock): CoreThemeFactoryInterface
{
$coreThemeFactoryMock = $this->createMock(CoreThemeFactoryInterface::class);
$coreThemeFactoryMock->expects($this->once())
Expand Down

0 comments on commit b0b6bf1

Please sign in to comment.