Skip to content

Commit

Permalink
OXDEV-8593 Added parentTheme and parentVersions fields to the ThemeDa…
Browse files Browse the repository at this point in the history
…taType
  • Loading branch information
tkcreateit committed Dec 6, 2024
1 parent bf2f233 commit 8d6fbc9
Show file tree
Hide file tree
Showing 7 changed files with 55 additions and 2 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [undecided] - Unreleased

### Added
- New `parentTheme` and `parentVersions` fields in the `ThemeDataType`

## [1.2.0] - 2024-11-27
This is the stable release of v1.2.0. No changes have been made since v1.2.0-rc.1.

Expand Down
27 changes: 27 additions & 0 deletions src/Theme/DataType/ThemeDataType.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,36 @@
namespace OxidEsales\GraphQL\ConfigurationAccess\Theme\DataType;

use OxidEsales\GraphQL\ConfigurationAccess\Shared\DataType\AbstractComponentDataType;
use TheCodingMachine\GraphQLite\Annotations\Field;
use TheCodingMachine\GraphQLite\Annotations\Type;

#[Type]
class ThemeDataType extends AbstractComponentDataType implements ThemeDataTypeInterface
{
public function __construct(
string $id,
string $title,
string $version,
string $description,
bool $active,
private readonly ?string $parentTheme,
private readonly ?array $parentVersions,
) {
parent::__construct($id, $title, $version, $description, $active);
}

#[Field]
public function getParentTheme(): ?string
{
return $this->parentTheme;
}

/**
* @return ?string[]
*/
#[Field]
public function getParentVersions(): ?array
{
return $this->parentVersions;
}
}
4 changes: 3 additions & 1 deletion src/Theme/DataType/ThemeDataTypeFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,9 @@ public function createFromCoreTheme(
title: $theme->getInfo('title'),
version: $theme->getInfo('version'),
description: $theme->getInfo('description'),
active: $theme->getInfo('active')
active: $theme->getInfo('active'),
parentTheme: $theme->getInfo('parentTheme'),
parentVersions: $theme->getInfo('parentVersions'),
);
}
}
9 changes: 9 additions & 0 deletions src/Theme/DataType/ThemeDataTypeInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,18 @@
namespace OxidEsales\GraphQL\ConfigurationAccess\Theme\DataType;

use OxidEsales\GraphQL\ConfigurationAccess\Shared\DataType\ComponentDataTypeInterface;
use TheCodingMachine\GraphQLite\Annotations\Field;
use TheCodingMachine\GraphQLite\Annotations\Type;

#[Type]
interface ThemeDataTypeInterface extends ComponentDataTypeInterface
{
#[Field]
public function getParentTheme(): ?string;

/**
* @return ?string[]
*/
#[Field]
public function getParentVersions(): ?array;
}
2 changes: 2 additions & 0 deletions tests/Codeception/Acceptance/Theme/ThemeListCest.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ private function runThemeListQuery(AcceptanceTester $I): array
version
description
active
parentTheme
parentVersions
}
}'
);
Expand Down
4 changes: 4 additions & 0 deletions tests/Unit/Theme/DataType/ThemeDataTypeFactoryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ public function testCreateThemeDataType(): void
$expectedVersion = uniqid();
$expectedDescription = uniqid();
$expectedActive = true;
$expectedParentTheme = uniqid();
$expectedParentVersions = [uniqid(), uniqid()];

$themeMock->method('getInfo')
->willReturnMap([
Expand All @@ -36,6 +38,8 @@ public function testCreateThemeDataType(): void
['version', $expectedVersion],
['description', $expectedDescription],
['active', $expectedActive],
['parentTheme', $expectedParentTheme],
['parentVersions', $expectedParentVersions],
]);

$factory = new ThemeDataTypeFactory();
Expand Down
6 changes: 5 additions & 1 deletion tests/Unit/Theme/DataType/ThemeDataTypeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,18 @@ public function testThemeDataType(): void
$version = uniqid();
$description = uniqid();
$active = (bool)random_int(0, 1);
$parentTheme = uniqid();
$parentVersions = [uniqid(), uniqid()];

$sut = new ThemeDataType($id, $name, $version, $description, $active);
$sut = new ThemeDataType($id, $name, $version, $description, $active, $parentTheme, $parentVersions);

$this->assertInstanceOf(ComponentDataTypeInterface::class, $sut);
$this->assertSame($name, $sut->getTitle());
$this->assertSame($id, $sut->getId());
$this->assertSame($version, $sut->getVersion());
$this->assertSame($description, $sut->getDescription());
$this->assertSame($active, $sut->isActive());
$this->assertSame($parentTheme, $sut->getParentTheme());
$this->assertSame($parentVersions, $sut->getParentVersions());
}
}

0 comments on commit 8d6fbc9

Please sign in to comment.