From bcc30d15aea63d9b0b2aecd9a6ad393cf9f84fb3 Mon Sep 17 00:00:00 2001 From: marcelmanzel Date: Thu, 8 Aug 2024 13:23:29 +0200 Subject: [PATCH] OXDEV-8215: Add lang property to ModuleDataType --- src/Module/DataType/ModuleDataType.php | 12 +++++++++++- src/Module/DataType/ModuleDataTypeFactory.php | 3 ++- src/Module/DataType/ModuleDataTypeInterface.php | 2 +- .../Module/Controller/ModuleListControllerTest.php | 1 - .../Module/DataType/ModuleDataTypeFactoryTest.php | 1 + tests/Unit/Module/DataType/ModuleDataTypeTest.php | 10 ++++++---- .../Theme/Controller/ThemeListControllerTest.php | 1 - tests/Unit/Theme/DataType/ThemeDataTypeTest.php | 2 +- 8 files changed, 22 insertions(+), 10 deletions(-) diff --git a/src/Module/DataType/ModuleDataType.php b/src/Module/DataType/ModuleDataType.php index c1705aa..93b14c1 100644 --- a/src/Module/DataType/ModuleDataType.php +++ b/src/Module/DataType/ModuleDataType.php @@ -16,6 +16,9 @@ #[Type] final class ModuleDataType extends AbstractComponentDataType implements ModuleDataTypeInterface { + /** + * @SuppressWarnings(PHPMD.ExcessiveParameterList) + */ public function __construct( string $id, string $title, @@ -25,7 +28,8 @@ public function __construct( private readonly ?string $thumbnail, private readonly ?string $author, private readonly ?string $url, - private readonly ?string $email + private readonly ?string $email, + private readonly string $lang ) { parent::__construct($id, $title, $version, $description, $active); } @@ -53,4 +57,10 @@ public function getEmail(): ?string { return $this->email; } + + #[Field] + public function getLang(): string + { + return $this->lang; + } } diff --git a/src/Module/DataType/ModuleDataTypeFactory.php b/src/Module/DataType/ModuleDataTypeFactory.php index 25e816e..ac25d59 100644 --- a/src/Module/DataType/ModuleDataTypeFactory.php +++ b/src/Module/DataType/ModuleDataTypeFactory.php @@ -43,7 +43,8 @@ public function createFromModuleConfiguration( thumbnail: $moduleConfig->getThumbnail(), author: $moduleConfig->getAuthor(), url: $moduleConfig->getUrl(), - email: $moduleConfig->getEmail() + email: $moduleConfig->getEmail(), + lang: $moduleConfig->getLang() ); } } diff --git a/src/Module/DataType/ModuleDataTypeInterface.php b/src/Module/DataType/ModuleDataTypeInterface.php index 35dfe45..2844785 100644 --- a/src/Module/DataType/ModuleDataTypeInterface.php +++ b/src/Module/DataType/ModuleDataTypeInterface.php @@ -27,5 +27,5 @@ public function getUrl(): ?string; public function getEmail(): ?string; #[Field] - public function isActive(): bool; + public function getLang(): string; } diff --git a/tests/Unit/Module/Controller/ModuleListControllerTest.php b/tests/Unit/Module/Controller/ModuleListControllerTest.php index dc7cadd..4c3b863 100644 --- a/tests/Unit/Module/Controller/ModuleListControllerTest.php +++ b/tests/Unit/Module/Controller/ModuleListControllerTest.php @@ -12,7 +12,6 @@ use OxidEsales\GraphQL\ConfigurationAccess\Module\Controller\ModuleListController; use OxidEsales\GraphQL\ConfigurationAccess\Module\Service\ModuleListServiceInterface; use OxidEsales\GraphQL\ConfigurationAccess\Shared\DataType\ComponentFilters; -use OxidEsales\GraphQL\ConfigurationAccess\Shared\DataType\ComponentFiltersInterface; use OxidEsales\GraphQL\ConfigurationAccess\Tests\Unit\UnitTestCase; use OxidEsales\GraphQL\ConfigurationAccess\Module\DataType\ModuleDataTypeInterface; diff --git a/tests/Unit/Module/DataType/ModuleDataTypeFactoryTest.php b/tests/Unit/Module/DataType/ModuleDataTypeFactoryTest.php index 91f119b..9659bd4 100644 --- a/tests/Unit/Module/DataType/ModuleDataTypeFactoryTest.php +++ b/tests/Unit/Module/DataType/ModuleDataTypeFactoryTest.php @@ -72,5 +72,6 @@ public function testCreateFromCoreModule() $this->assertSame($expectedUrl, $moduleDataType->getUrl()); $this->assertSame($expectedEmail, $moduleDataType->getEmail()); $this->assertSame($expectedIsActivated, $moduleDataType->isActive()); + $this->assertSame($expectedLang, $moduleDataType->getLang()); } } diff --git a/tests/Unit/Module/DataType/ModuleDataTypeTest.php b/tests/Unit/Module/DataType/ModuleDataTypeTest.php index 5019b23..8e0a2ad 100644 --- a/tests/Unit/Module/DataType/ModuleDataTypeTest.php +++ b/tests/Unit/Module/DataType/ModuleDataTypeTest.php @@ -12,6 +12,7 @@ use OxidEsales\GraphQL\ConfigurationAccess\Module\DataType\ModuleDataType; use OxidEsales\GraphQL\ConfigurationAccess\Shared\DataType\ComponentDataTypeInterface; use OxidEsales\GraphQL\ConfigurationAccess\Tests\Unit\UnitTestCase; +use phpDocumentor\Reflection\DocBlock\Description; /** * @covers \OxidEsales\GraphQL\ConfigurationAccess\Module\DataType\ModuleDataType @@ -24,18 +25,19 @@ public function testModuleDataType(): void $author = uniqid(); $url = uniqid(); $email = uniqid(); - $active = (bool)random_int(0, 1); + $lang = uniqid(); $moduleDataType = new ModuleDataType( id: uniqid(), title: uniqid(), version: uniqid(), description: uniqid(), - active: $active, + active: false, thumbnail: $thumbnail, author: $author, url: $url, - email: $email + email: $email, + lang: $lang ); $this->assertInstanceOf(ComponentDataTypeInterface::class, $moduleDataType); @@ -43,6 +45,6 @@ public function testModuleDataType(): void $this->assertSame($author, $moduleDataType->getAuthor()); $this->assertSame($url, $moduleDataType->getUrl()); $this->assertSame($email, $moduleDataType->getEmail()); - $this->assertSame($active, $moduleDataType->isActive()); + $this->assertSame($lang, $moduleDataType->getLang()); } } diff --git a/tests/Unit/Theme/Controller/ThemeListControllerTest.php b/tests/Unit/Theme/Controller/ThemeListControllerTest.php index 31a60fc..42c137b 100644 --- a/tests/Unit/Theme/Controller/ThemeListControllerTest.php +++ b/tests/Unit/Theme/Controller/ThemeListControllerTest.php @@ -10,7 +10,6 @@ namespace OxidEsales\GraphQL\ConfigurationAccess\Tests\Unit\Theme\Controller; use OxidEsales\GraphQL\ConfigurationAccess\Shared\DataType\ComponentFilters; -use OxidEsales\GraphQL\ConfigurationAccess\Shared\DataType\ComponentFiltersInterface; use OxidEsales\GraphQL\ConfigurationAccess\Theme\Controller\ThemeListController; use OxidEsales\GraphQL\ConfigurationAccess\Theme\DataType\ThemeDataTypeInterface; use OxidEsales\GraphQL\ConfigurationAccess\Theme\Service\ThemeListServiceInterface; diff --git a/tests/Unit/Theme/DataType/ThemeDataTypeTest.php b/tests/Unit/Theme/DataType/ThemeDataTypeTest.php index efc5cc3..cb8d7b9 100644 --- a/tests/Unit/Theme/DataType/ThemeDataTypeTest.php +++ b/tests/Unit/Theme/DataType/ThemeDataTypeTest.php @@ -24,7 +24,7 @@ public function testThemeDataType(): void $id = uniqid(); $version = uniqid(); $description = uniqid(); - $active = true; + $active = (bool)random_int(0, 1); $sut = new ThemeDataType($id, $name, $version, $description, $active);