Skip to content

Commit

Permalink
OXDEV-8215: Add lang property to ModuleDataType
Browse files Browse the repository at this point in the history
  • Loading branch information
MarcelOxid committed Aug 8, 2024
1 parent 854121c commit bcc30d1
Show file tree
Hide file tree
Showing 8 changed files with 22 additions and 10 deletions.
12 changes: 11 additions & 1 deletion src/Module/DataType/ModuleDataType.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@
#[Type]
final class ModuleDataType extends AbstractComponentDataType implements ModuleDataTypeInterface
{
/**
* @SuppressWarnings(PHPMD.ExcessiveParameterList)
*/
public function __construct(
string $id,
string $title,
Expand All @@ -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);
}
Expand Down Expand Up @@ -53,4 +57,10 @@ public function getEmail(): ?string
{
return $this->email;
}

#[Field]
public function getLang(): string
{
return $this->lang;
}
}
3 changes: 2 additions & 1 deletion src/Module/DataType/ModuleDataTypeFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -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()
);
}
}
2 changes: 1 addition & 1 deletion src/Module/DataType/ModuleDataTypeInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,5 +27,5 @@ public function getUrl(): ?string;
public function getEmail(): ?string;

#[Field]
public function isActive(): bool;
public function getLang(): string;
}
1 change: 0 additions & 1 deletion tests/Unit/Module/Controller/ModuleListControllerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
1 change: 1 addition & 0 deletions tests/Unit/Module/DataType/ModuleDataTypeFactoryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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());
}
}
10 changes: 6 additions & 4 deletions tests/Unit/Module/DataType/ModuleDataTypeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -24,25 +25,26 @@ 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);
$this->assertSame($thumbnail, $moduleDataType->getThumbnail());
$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());
}
}
1 change: 0 additions & 1 deletion tests/Unit/Theme/Controller/ThemeListControllerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion tests/Unit/Theme/DataType/ThemeDataTypeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down

0 comments on commit bcc30d1

Please sign in to comment.