From 9b8abd8a9dcbfa9352c4481bf67273cf05cc2408 Mon Sep 17 00:00:00 2001 From: Anton Fedurtsya Date: Mon, 4 Dec 2023 16:37:19 +0200 Subject: [PATCH] OXDEV-7646 Remove usage of ID in DataTypes Signed-off-by: Anton Fedurtsya --- src/Setting/DataType/BooleanSetting.php | 5 ++- src/Setting/DataType/FloatSetting.php | 4 +-- src/Setting/DataType/IntegerSetting.php | 5 ++- src/Setting/DataType/SettingType.php | 5 ++- src/Setting/DataType/StringSetting.php | 5 ++- src/Setting/Service/ModuleSettingService.php | 33 +++++++++-------- src/Setting/Service/ShopSettingService.php | 17 +++++---- src/Setting/Service/ThemeSettingService.php | 17 +++++---- .../ModuleSettingControllerTest.php | 27 +++++++------- .../Controller/ShopSettingControllerTest.php | 36 +++++++++---------- .../Controller/ThemeSettingControllerTest.php | 36 +++++++++---------- tests/Unit/DataType/BooleanSettingTest.php | 7 ++-- tests/Unit/DataType/FloatSettingTest.php | 7 ++-- tests/Unit/DataType/IntegerSettingTest.php | 5 ++- tests/Unit/DataType/SettingTypeTest.php | 5 ++- tests/Unit/DataType/StringSettingTest.php | 5 ++- .../Unit/Service/ModuleSettingServiceTest.php | 31 ++++++---------- tests/Unit/Service/ShopSettingServiceTest.php | 31 ++++++++-------- .../Unit/Service/ThemeSettingServiceTest.php | 29 ++++++++------- tests/Unit/UnitTestCase.php | 6 ++-- 20 files changed, 143 insertions(+), 173 deletions(-) diff --git a/src/Setting/DataType/BooleanSetting.php b/src/Setting/DataType/BooleanSetting.php index df89511..340901f 100644 --- a/src/Setting/DataType/BooleanSetting.php +++ b/src/Setting/DataType/BooleanSetting.php @@ -11,19 +11,18 @@ use TheCodingMachine\GraphQLite\Annotations\Field; use TheCodingMachine\GraphQLite\Annotations\Type; -use TheCodingMachine\GraphQLite\Types\ID; #[Type] final class BooleanSetting { public function __construct( - private ID $name, + private string $name, private bool $value ) { } #[Field] - public function getName(): ID + public function getName(): string { return $this->name; } diff --git a/src/Setting/DataType/FloatSetting.php b/src/Setting/DataType/FloatSetting.php index eb87ef1..b415fe3 100644 --- a/src/Setting/DataType/FloatSetting.php +++ b/src/Setting/DataType/FloatSetting.php @@ -17,13 +17,13 @@ final class FloatSetting { public function __construct( - private ID $name, + private string $name, private float $value ) { } #[Field] - public function getName(): ID + public function getName(): string { return $this->name; } diff --git a/src/Setting/DataType/IntegerSetting.php b/src/Setting/DataType/IntegerSetting.php index 04933c2..37b7a6d 100644 --- a/src/Setting/DataType/IntegerSetting.php +++ b/src/Setting/DataType/IntegerSetting.php @@ -11,19 +11,18 @@ use TheCodingMachine\GraphQLite\Annotations\Field; use TheCodingMachine\GraphQLite\Annotations\Type; -use TheCodingMachine\GraphQLite\Types\ID; #[Type] final class IntegerSetting { public function __construct( - private ID $name, + private string $name, private int $value ) { } #[Field] - public function getName(): ID + public function getName(): string { return $this->name; } diff --git a/src/Setting/DataType/SettingType.php b/src/Setting/DataType/SettingType.php index 4411e2b..1bff416 100644 --- a/src/Setting/DataType/SettingType.php +++ b/src/Setting/DataType/SettingType.php @@ -12,19 +12,18 @@ use OxidEsales\GraphQL\ConfigurationAccess\Setting\Enum\FieldType; use TheCodingMachine\GraphQLite\Annotations\Field; use TheCodingMachine\GraphQLite\Annotations\Type; -use TheCodingMachine\GraphQLite\Types\ID; #[Type] final class SettingType { public function __construct( - private ID $name, + private string $name, private string $type ) { } #[Field] - public function getName(): ID + public function getName(): string { return $this->name; } diff --git a/src/Setting/DataType/StringSetting.php b/src/Setting/DataType/StringSetting.php index 5bde063..d63eae0 100644 --- a/src/Setting/DataType/StringSetting.php +++ b/src/Setting/DataType/StringSetting.php @@ -11,19 +11,18 @@ use TheCodingMachine\GraphQLite\Annotations\Field; use TheCodingMachine\GraphQLite\Annotations\Type; -use TheCodingMachine\GraphQLite\Types\ID; #[Type] final class StringSetting { public function __construct( - private ID $name, + private string $name, private string $value ) { } #[Field] - public function getName(): ID + public function getName(): string { return $this->name; } diff --git a/src/Setting/Service/ModuleSettingService.php b/src/Setting/Service/ModuleSettingService.php index 85e9efd..ac578ef 100644 --- a/src/Setting/Service/ModuleSettingService.php +++ b/src/Setting/Service/ModuleSettingService.php @@ -16,7 +16,6 @@ use OxidEsales\GraphQL\ConfigurationAccess\Setting\DataType\SettingType; use OxidEsales\GraphQL\ConfigurationAccess\Setting\DataType\StringSetting; use OxidEsales\GraphQL\ConfigurationAccess\Setting\Infrastructure\ModuleSettingRepositoryInterface; -use TheCodingMachine\GraphQLite\Types\ID; final class ModuleSettingService implements ModuleSettingServiceInterface { @@ -29,69 +28,69 @@ public function __construct( public function getIntegerSetting(string $name, string $moduleId): IntegerSetting { return new IntegerSetting( - new ID($name), - $this->moduleSettingRepository->getIntegerSetting((string)$name, $moduleId) + $name, + $this->moduleSettingRepository->getIntegerSetting($name, $moduleId) ); } public function getFloatSetting(string $name, string $moduleId): FloatSetting { return new FloatSetting( - new ID($name), - $this->moduleSettingRepository->getFloatSetting((string)$name, $moduleId) + $name, + $this->moduleSettingRepository->getFloatSetting($name, $moduleId) ); } public function getBooleanSetting(string $name, string $moduleId): BooleanSetting { return new BooleanSetting( - new ID($name), - $this->moduleSettingRepository->getBooleanSetting((string)$name, $moduleId) + $name, + $this->moduleSettingRepository->getBooleanSetting($name, $moduleId) ); } public function getStringSetting(string $name, string $moduleId): StringSetting { return new StringSetting( - new ID($name), - $this->moduleSettingRepository->getStringSetting((string)$name, $moduleId) + $name, + $this->moduleSettingRepository->getStringSetting($name, $moduleId) ); } public function getCollectionSetting(string $name, string $moduleId): StringSetting { - $collection = $this->moduleSettingRepository->getCollectionSetting((string)$name, $moduleId); + $collection = $this->moduleSettingRepository->getCollectionSetting($name, $moduleId); return new StringSetting( - new ID($name), + $name, $this->jsonService->jsonEncodeArray($collection) ); } public function changeIntegerSetting(string $name, int $value, string $moduleId): IntegerSetting { - $this->moduleSettingRepository->saveIntegerSetting((string)$name, $value, $moduleId); + $this->moduleSettingRepository->saveIntegerSetting($name, $value, $moduleId); return $this->getIntegerSetting($name, $moduleId); } public function changeFloatSetting(string $name, float $value, string $moduleId): FloatSetting { - $this->moduleSettingRepository->saveFloatSetting((string)$name, $value, $moduleId); + $this->moduleSettingRepository->saveFloatSetting($name, $value, $moduleId); return $this->getFloatSetting($name, $moduleId); } public function changeBooleanSetting(string $name, bool $value, string $moduleId): BooleanSetting { - $this->moduleSettingRepository->saveBooleanSetting((string)$name, $value, $moduleId); + $this->moduleSettingRepository->saveBooleanSetting($name, $value, $moduleId); return $this->getBooleanSetting($name, $moduleId); } public function changeStringSetting(string $name, string $value, string $moduleId): StringSetting { - $this->moduleSettingRepository->saveStringSetting((string)$name, $value, $moduleId); + $this->moduleSettingRepository->saveStringSetting($name, $value, $moduleId); return $this->getStringSetting($name, $moduleId); } @@ -99,7 +98,7 @@ public function changeStringSetting(string $name, string $value, string $moduleI public function changeCollectionSetting(string $name, string $value, string $moduleId): StringSetting { $this->moduleSettingRepository->saveCollectionSetting( - (string)$name, + $name, $this->jsonService->jsonDecodeCollection($value), $moduleId ); @@ -116,7 +115,7 @@ public function getSettingsList(string $moduleId): array $settingTypes = []; /** @var Setting $setting */ foreach ($settingsList as $setting) { - $settingTypes[] = new SettingType(new ID($setting->getName()), $setting->getType()); + $settingTypes[] = new SettingType($setting->getName(), $setting->getType()); } return $settingTypes; diff --git a/src/Setting/Service/ShopSettingService.php b/src/Setting/Service/ShopSettingService.php index 2347669..243eaed 100644 --- a/src/Setting/Service/ShopSettingService.php +++ b/src/Setting/Service/ShopSettingService.php @@ -15,7 +15,6 @@ use OxidEsales\GraphQL\ConfigurationAccess\Setting\DataType\SettingType; use OxidEsales\GraphQL\ConfigurationAccess\Setting\DataType\StringSetting; use OxidEsales\GraphQL\ConfigurationAccess\Setting\Infrastructure\ShopSettingRepositoryInterface; -use TheCodingMachine\GraphQLite\Types\ID; final class ShopSettingService implements ShopSettingServiceInterface { @@ -28,31 +27,31 @@ public function __construct( public function getIntegerSetting(string $name): IntegerSetting { $integer = $this->shopSettingRepository->getInteger($name); - return new IntegerSetting(new ID($name), $integer); + return new IntegerSetting($name, $integer); } public function getFloatSetting(string $name): FloatSetting { $float = $this->shopSettingRepository->getFloat($name); - return new FloatSetting(new ID($name), $float); + return new FloatSetting($name, $float); } public function getBooleanSetting(string $name): BooleanSetting { $bool = $this->shopSettingRepository->getBoolean($name); - return new BooleanSetting(new ID($name), $bool); + return new BooleanSetting($name, $bool); } public function getStringSetting(string $name): StringSetting { $string = $this->shopSettingRepository->getString($name); - return new StringSetting(new ID($name), $string); + return new StringSetting($name, $string); } public function getSelectSetting(string $name): StringSetting { $select = $this->shopSettingRepository->getSelect($name); - return new StringSetting(new ID($name), $select); + return new StringSetting($name, $select); } public function getCollectionSetting(string $name): StringSetting @@ -60,7 +59,7 @@ public function getCollectionSetting(string $name): StringSetting $collectionString = $this->shopSettingRepository->getCollection($name); $collectionEncodingResult = $this->jsonService->jsonEncodeArray($collectionString); - return new StringSetting(new ID($name), $collectionEncodingResult); + return new StringSetting($name, $collectionEncodingResult); } public function getAssocCollectionSetting(string $name): StringSetting @@ -68,7 +67,7 @@ public function getAssocCollectionSetting(string $name): StringSetting $assocCollectionString = $this->shopSettingRepository->getAssocCollection($name); $assocCollectionEncodingResult = $this->jsonService->jsonEncodeArray($assocCollectionString); - return new StringSetting(new ID($name), $assocCollectionEncodingResult); + return new StringSetting($name, $assocCollectionEncodingResult); } /** @@ -79,7 +78,7 @@ public function getSettingsList(): array $settingsList = $this->shopSettingRepository->getSettingsList(); $settingsTypeList = []; foreach ($settingsList as $name => $type) { - $settingsTypeList[] = new SettingType(new ID($name), $type); + $settingsTypeList[] = new SettingType($name, $type); } return $settingsTypeList; diff --git a/src/Setting/Service/ThemeSettingService.php b/src/Setting/Service/ThemeSettingService.php index 6740e12..2b088e9 100644 --- a/src/Setting/Service/ThemeSettingService.php +++ b/src/Setting/Service/ThemeSettingService.php @@ -16,7 +16,6 @@ use OxidEsales\GraphQL\ConfigurationAccess\Setting\DataType\StringSetting; use OxidEsales\GraphQL\ConfigurationAccess\Setting\Exception\InvalidCollectionException; use OxidEsales\GraphQL\ConfigurationAccess\Setting\Infrastructure\ThemeSettingRepositoryInterface; -use TheCodingMachine\GraphQLite\Types\ID; final class ThemeSettingService implements ThemeSettingServiceInterface { @@ -29,31 +28,31 @@ public function __construct( public function getIntegerSetting(string $name, string $themeId): IntegerSetting { $integer = $this->themeSettingRepository->getInteger($name, $themeId); - return new IntegerSetting(new ID($name), $integer); + return new IntegerSetting($name, $integer); } public function getFloatSetting(string $name, string $themeId): FloatSetting { $float = $this->themeSettingRepository->getFloat($name, $themeId); - return new FloatSetting(new ID($name), $float); + return new FloatSetting($name, $float); } public function getBooleanSetting(string $name, string $themeId): BooleanSetting { $bool = $this->themeSettingRepository->getBoolean($name, $themeId); - return new BooleanSetting(new ID($name), $bool); + return new BooleanSetting($name, $bool); } public function getStringSetting(string $name, string $themeId): StringSetting { $string = $this->themeSettingRepository->getString($name, $themeId); - return new StringSetting(new ID($name), $string); + return new StringSetting($name, $string); } public function getSelectSetting(string $name, string $themeId): StringSetting { $select = $this->themeSettingRepository->getSelect($name, $themeId); - return new StringSetting(new ID($name), $select); + return new StringSetting($name, $select); } public function getCollectionSetting(string $name, string $themeId): StringSetting @@ -61,7 +60,7 @@ public function getCollectionSetting(string $name, string $themeId): StringSetti $collection = $this->themeSettingRepository->getCollection($name, $themeId); $collectionEncodingResult = $this->jsonService->jsonEncodeArray($collection); - return new StringSetting(new ID($name), $collectionEncodingResult); + return new StringSetting($name, $collectionEncodingResult); } public function getAssocCollectionSetting(string $name, string $themeId): StringSetting @@ -69,7 +68,7 @@ public function getAssocCollectionSetting(string $name, string $themeId): String $assocCollection = $this->themeSettingRepository->getAssocCollection($name, $themeId); $collectionEncodingResult = $this->jsonService->jsonEncodeArray($assocCollection); - return new StringSetting(new ID($name), $collectionEncodingResult); + return new StringSetting($name, $collectionEncodingResult); } /** @@ -80,7 +79,7 @@ public function getSettingsList(string $themeId): array $settingsList = $this->themeSettingRepository->getSettingsList($themeId); $settingsTypeList = []; foreach ($settingsList as $name => $type) { - $settingsTypeList[] = new SettingType(new ID($name), $type); + $settingsTypeList[] = new SettingType($name, $type); } return $settingsTypeList; diff --git a/tests/Unit/Controller/ModuleSettingControllerTest.php b/tests/Unit/Controller/ModuleSettingControllerTest.php index 38e5db8..e4bcbbe 100644 --- a/tests/Unit/Controller/ModuleSettingControllerTest.php +++ b/tests/Unit/Controller/ModuleSettingControllerTest.php @@ -43,83 +43,82 @@ public function testControllerProxiesParametersToServiceAndReturnsItsResult( public function proxyTestDataProvider(): \Generator { $settingName = 'settingName'; - $settingNameID = new ID($settingName); yield 'getter integer' => [ 'controllerMethod' => 'getModuleSettingInteger', 'serviceMethod' => 'getIntegerSetting', 'params' => [$settingName, 'awesomeModule'], - 'expectedValue' => new IntegerSetting($settingNameID, 123) + 'expectedValue' => new IntegerSetting($settingName, 123) ]; yield 'getter float' => [ 'controllerMethod' => 'getModuleSettingFloat', 'serviceMethod' => 'getFloatSetting', 'params' => [$settingName, 'awesomeModule'], - 'expectedValue' => new FloatSetting($settingNameID, 1.23) + 'expectedValue' => new FloatSetting($settingName, 1.23) ]; yield 'getter bool' => [ 'controllerMethod' => 'getModuleSettingBoolean', 'serviceMethod' => 'getBooleanSetting', 'params' => [$settingName, 'awesomeModule'], - 'expectedValue' => new BooleanSetting($settingNameID, false) + 'expectedValue' => new BooleanSetting($settingName, false) ]; yield 'getter string' => [ 'controllerMethod' => 'getModuleSettingString', 'serviceMethod' => 'getStringSetting', 'params' => [$settingName, 'awesomeModule'], - 'expectedValue' => new StringSetting($settingNameID, 'default') + 'expectedValue' => new StringSetting($settingName, 'default') ]; yield 'getter collection' => [ 'controllerMethod' => 'getModuleSettingCollection', 'serviceMethod' => 'getCollectionSetting', 'params' => [$settingName, 'awesomeModule'], - 'expectedValue' => new StringSetting($settingNameID, 'someCollectionStringExample') + 'expectedValue' => new StringSetting($settingName, 'someCollectionStringExample') ]; yield 'setter integer' => [ 'controllerMethod' => 'changeModuleSettingInteger', 'serviceMethod' => 'changeIntegerSetting', 'params' => [$settingName, 123, 'awesomeModule'], - 'expectedValue' => new IntegerSetting($settingNameID, 123) + 'expectedValue' => new IntegerSetting($settingName, 123) ]; yield 'setter float' => [ 'controllerMethod' => 'changeModuleSettingFloat', 'serviceMethod' => 'changeFloatSetting', 'params' => [$settingName, 1.23, 'awesomeModule'], - 'expectedValue' => new FloatSetting($settingNameID, 1.23) + 'expectedValue' => new FloatSetting($settingName, 1.23) ]; yield 'setter float with integer value' => [ 'controllerMethod' => 'changeModuleSettingFloat', 'serviceMethod' => 'changeFloatSetting', 'params' => [$settingName, 123, 'awesomeModule'], - 'expectedValue' => new FloatSetting($settingNameID, 123) + 'expectedValue' => new FloatSetting($settingName, 123) ]; yield 'setter boolean' => [ 'controllerMethod' => 'changeModuleSettingBoolean', 'serviceMethod' => 'changeBooleanSetting', 'params' => [$settingName, false, 'awesomeModule'], - 'expectedValue' => new BooleanSetting($settingNameID, false) + 'expectedValue' => new BooleanSetting($settingName, false) ]; yield 'setter string' => [ 'controllerMethod' => 'changeModuleSettingString', 'serviceMethod' => 'changeStringSetting', 'params' => [$settingName, 'some string', 'awesomeModule'], - 'expectedValue' => new StringSetting($settingNameID, 'some string') + 'expectedValue' => new StringSetting($settingName, 'some string') ]; yield 'setter collection' => [ 'controllerMethod' => 'changeModuleSettingCollection', 'serviceMethod' => 'changeCollectionSetting', 'params' => [$settingName, 'some collection string', 'awesomeModule'], - 'expectedValue' => new StringSetting($settingNameID, 'some collection string') + 'expectedValue' => new StringSetting($settingName, 'some collection string') ]; yield 'list query' => [ @@ -127,8 +126,8 @@ public function proxyTestDataProvider(): \Generator 'serviceMethod' => 'getSettingsList', 'params' => ['awesomeModule'], 'expectedValue' => [ - new SettingType($settingNameID, FieldType::NUMBER), - new SettingType($settingNameID, FieldType::NUMBER), + new SettingType($settingName, FieldType::NUMBER), + new SettingType($settingName, FieldType::NUMBER), ] ]; } diff --git a/tests/Unit/Controller/ShopSettingControllerTest.php b/tests/Unit/Controller/ShopSettingControllerTest.php index 4d2ba27..f2ee6e3 100644 --- a/tests/Unit/Controller/ShopSettingControllerTest.php +++ b/tests/Unit/Controller/ShopSettingControllerTest.php @@ -18,7 +18,6 @@ use OxidEsales\GraphQL\ConfigurationAccess\Setting\Enum\FieldType; use OxidEsales\GraphQL\ConfigurationAccess\Setting\Service\ShopSettingServiceInterface; use PHPUnit\Framework\TestCase; -use TheCodingMachine\GraphQLite\Types\ID; /** * @covers \OxidEsales\GraphQL\ConfigurationAccess\Setting\Controller\ShopSettingController @@ -43,111 +42,110 @@ public function testControllerProxiesParametersToServiceAndReturnsItsResult( public function proxyTestDataProvider(): \Generator { $settingName = 'settingName'; - $settingNameID = new ID($settingName); yield 'getter integer' => [ 'controllerMethod' => 'getShopSettingInteger', 'serviceMethod' => 'getIntegerSetting', 'params' => [$settingName], - 'expectedValue' => new IntegerSetting($settingNameID, 123) + 'expectedValue' => new IntegerSetting($settingName, 123) ]; yield 'getter float' => [ 'controllerMethod' => 'getShopSettingFloat', 'serviceMethod' => 'getFloatSetting', 'params' => [$settingName], - 'expectedValue' => new FloatSetting($settingNameID, 1.23) + 'expectedValue' => new FloatSetting($settingName, 1.23) ]; yield 'getter bool' => [ 'controllerMethod' => 'getShopSettingBoolean', 'serviceMethod' => 'getBooleanSetting', 'params' => [$settingName], - 'expectedValue' => new BooleanSetting($settingNameID, false) + 'expectedValue' => new BooleanSetting($settingName, false) ]; yield 'getter string' => [ 'controllerMethod' => 'getShopSettingString', 'serviceMethod' => 'getStringSetting', 'params' => [$settingName], - 'expectedValue' => new StringSetting($settingNameID, 'default') + 'expectedValue' => new StringSetting($settingName, 'default') ]; yield 'getter select' => [ 'controllerMethod' => 'getShopSettingSelect', 'serviceMethod' => 'getSelectSetting', 'params' => [$settingName], - 'expectedValue' => new StringSetting($settingNameID, 'some select setting value') + 'expectedValue' => new StringSetting($settingName, 'some select setting value') ]; yield 'getter collection' => [ 'controllerMethod' => 'getShopSettingCollection', 'serviceMethod' => 'getCollectionSetting', 'params' => [$settingName], - 'expectedValue' => new StringSetting($settingNameID, 'some collection string example') + 'expectedValue' => new StringSetting($settingName, 'some collection string example') ]; yield 'getter associative collection' => [ 'controllerMethod' => 'getShopSettingAssocCollection', 'serviceMethod' => 'getAssocCollectionSetting', 'params' => [$settingName], - 'expectedValue' => new StringSetting($settingNameID, 'some associative collection string example') + 'expectedValue' => new StringSetting($settingName, 'some associative collection string example') ]; yield 'setter integer' => [ 'controllerMethod' => 'changeShopSettingInteger', 'serviceMethod' => 'changeIntegerSetting', 'params' => [$settingName, 123], - 'expectedValue' => new IntegerSetting($settingNameID, 123) + 'expectedValue' => new IntegerSetting($settingName, 123) ]; yield 'setter float' => [ 'controllerMethod' => 'changeShopSettingFloat', 'serviceMethod' => 'changeFloatSetting', 'params' => [$settingName, 1.23], - 'expectedValue' => new FloatSetting($settingNameID, 1.23) + 'expectedValue' => new FloatSetting($settingName, 1.23) ]; yield 'setter float with integer value' => [ 'controllerMethod' => 'changeShopSettingFloat', 'serviceMethod' => 'changeFloatSetting', 'params' => [$settingName, 123], - 'expectedValue' => new FloatSetting($settingNameID, 123) + 'expectedValue' => new FloatSetting($settingName, 123) ]; yield 'setter boolean' => [ 'controllerMethod' => 'changeShopSettingBoolean', 'serviceMethod' => 'changeBooleanSetting', 'params' => [$settingName, false], - 'expectedValue' => new BooleanSetting($settingNameID, false) + 'expectedValue' => new BooleanSetting($settingName, false) ]; yield 'setter string' => [ 'controllerMethod' => 'changeShopSettingString', 'serviceMethod' => 'changeStringSetting', 'params' => [$settingName, 'some string'], - 'expectedValue' => new StringSetting($settingNameID, 'some string') + 'expectedValue' => new StringSetting($settingName, 'some string') ]; yield 'setter select' => [ 'controllerMethod' => 'changeShopSettingSelect', 'serviceMethod' => 'changeSelectSetting', 'params' => [$settingName, 'some select value'], - 'expectedValue' => new StringSetting($settingNameID, 'some select value') + 'expectedValue' => new StringSetting($settingName, 'some select value') ]; yield 'setter collection' => [ 'controllerMethod' => 'changeShopSettingCollection', 'serviceMethod' => 'changeCollectionSetting', 'params' => [$settingName, 'some collection string'], - 'expectedValue' => new StringSetting($settingNameID, 'some collection string') + 'expectedValue' => new StringSetting($settingName, 'some collection string') ]; yield 'setter assoc collection' => [ 'controllerMethod' => 'changeShopSettingAssocCollection', 'serviceMethod' => 'changeAssocCollectionSetting', 'params' => [$settingName, 'some assoc collection string'], - 'expectedValue' => new StringSetting($settingNameID, 'some assoc collection string') + 'expectedValue' => new StringSetting($settingName, 'some assoc collection string') ]; yield 'setting list getter' => [ @@ -155,8 +153,8 @@ public function proxyTestDataProvider(): \Generator 'serviceMethod' => 'getSettingsList', 'params' => [], 'expectedValue' => [ - new SettingType($settingNameID, FieldType::NUMBER), - new SettingType($settingNameID, FieldType::NUMBER), + new SettingType($settingName, FieldType::NUMBER), + new SettingType($settingName, FieldType::NUMBER), ] ]; } diff --git a/tests/Unit/Controller/ThemeSettingControllerTest.php b/tests/Unit/Controller/ThemeSettingControllerTest.php index 52ae7cc..fb1b056 100644 --- a/tests/Unit/Controller/ThemeSettingControllerTest.php +++ b/tests/Unit/Controller/ThemeSettingControllerTest.php @@ -18,7 +18,6 @@ use OxidEsales\GraphQL\ConfigurationAccess\Setting\Enum\FieldType; use OxidEsales\GraphQL\ConfigurationAccess\Setting\Service\ThemeSettingServiceInterface; use PHPUnit\Framework\TestCase; -use TheCodingMachine\GraphQLite\Types\ID; /** * @covers \OxidEsales\GraphQL\ConfigurationAccess\Setting\Controller\ThemeSettingController @@ -43,111 +42,110 @@ public function testControllerProxiesParametersToServiceAndReturnsItsResult( public function proxyTestDataProvider(): \Generator { $name = 'settingName'; - $settingNameID = new ID($name); yield 'getter integer' => [ 'controllerMethod' => 'getThemeSettingInteger', 'serviceMethod' => 'getIntegerSetting', 'params' => [$name, 'awesomeTheme'], - 'expectedValue' => new IntegerSetting($settingNameID, 123) + 'expectedValue' => new IntegerSetting($name, 123) ]; yield 'getter float' => [ 'controllerMethod' => 'getThemeSettingFloat', 'serviceMethod' => 'getFloatSetting', 'params' => [$name, 'awesomeTheme'], - 'expectedValue' => new FloatSetting($settingNameID, 1.23) + 'expectedValue' => new FloatSetting($name, 1.23) ]; yield 'getter bool' => [ 'controllerMethod' => 'getThemeSettingBoolean', 'serviceMethod' => 'getBooleanSetting', 'params' => [$name, 'awesomeTheme'], - 'expectedValue' => new BooleanSetting($settingNameID, false) + 'expectedValue' => new BooleanSetting($name, false) ]; yield 'getter string' => [ 'controllerMethod' => 'getThemeSettingString', 'serviceMethod' => 'getStringSetting', 'params' => [$name, 'awesomeTheme'], - 'expectedValue' => new StringSetting($settingNameID, 'default') + 'expectedValue' => new StringSetting($name, 'default') ]; yield 'getter select' => [ 'controllerMethod' => 'getThemeSettingSelect', 'serviceMethod' => 'getSelectSetting', 'params' => [$name, 'awesomeTheme'], - 'expectedValue' => new StringSetting($settingNameID, 'some select setting value') + 'expectedValue' => new StringSetting($name, 'some select setting value') ]; yield 'getter collection' => [ 'controllerMethod' => 'getThemeSettingCollection', 'serviceMethod' => 'getCollectionSetting', 'params' => [$name, 'awesomeTheme'], - 'expectedValue' => new StringSetting($settingNameID, 'someCollectionStringExample') + 'expectedValue' => new StringSetting($name, 'someCollectionStringExample') ]; yield 'getter associative collection' => [ 'controllerMethod' => 'getThemeSettingAssocCollection', 'serviceMethod' => 'getAssocCollectionSetting', 'params' => [$name, 'awesomeTheme'], - 'expectedValue' => new StringSetting($settingNameID, 'some associative collection string example') + 'expectedValue' => new StringSetting($name, 'some associative collection string example') ]; yield 'setter integer' => [ 'controllerMethod' => 'changeThemeSettingInteger', 'serviceMethod' => 'changeIntegerSetting', 'params' => [$name, 123, 'awesomeTheme'], - 'expectedValue' => new IntegerSetting($settingNameID, 123) + 'expectedValue' => new IntegerSetting($name, 123) ]; yield 'setter float' => [ 'controllerMethod' => 'changeThemeSettingFloat', 'serviceMethod' => 'changeFloatSetting', 'params' => [$name, 1.23, 'awesomeTheme'], - 'expectedValue' => new FloatSetting($settingNameID, 1.23) + 'expectedValue' => new FloatSetting($name, 1.23) ]; yield 'setter float with integer value' => [ 'controllerMethod' => 'changeThemeSettingFloat', 'serviceMethod' => 'changeFloatSetting', 'params' => [$name, 123, 'awesomeTheme'], - 'expectedValue' => new FloatSetting($settingNameID, 123) + 'expectedValue' => new FloatSetting($name, 123) ]; yield 'setter boolean' => [ 'controllerMethod' => 'changeThemeSettingBoolean', 'serviceMethod' => 'changeBooleanSetting', 'params' => [$name, false, 'awesomeTheme'], - 'expectedValue' => new BooleanSetting($settingNameID, false) + 'expectedValue' => new BooleanSetting($name, false) ]; yield 'setter string' => [ 'controllerMethod' => 'changeThemeSettingString', 'serviceMethod' => 'changeStringSetting', 'params' => [$name, 'some string', 'awesomeTheme'], - 'expectedValue' => new StringSetting($settingNameID, 'some string') + 'expectedValue' => new StringSetting($name, 'some string') ]; yield 'setter select' => [ 'controllerMethod' => 'changeThemeSettingSelect', 'serviceMethod' => 'changeSelectSetting', 'params' => [$name, 'some string', 'awesomeTheme'], - 'expectedValue' => new StringSetting($settingNameID, 'some string') + 'expectedValue' => new StringSetting($name, 'some string') ]; yield 'setter collection' => [ 'controllerMethod' => 'changeThemeSettingCollection', 'serviceMethod' => 'changeCollectionSetting', 'params' => [$name, 'some collection string', 'awesomeTheme'], - 'expectedValue' => new StringSetting($settingNameID, 'some collection string') + 'expectedValue' => new StringSetting($name, 'some collection string') ]; yield 'setter assoc collection' => [ 'controllerMethod' => 'changeThemeSettingAssocCollection', 'serviceMethod' => 'changeAssocCollectionSetting', 'params' => [$name, 'some assoc collection string', 'awesomeTheme'], - 'expectedValue' => new StringSetting($settingNameID, 'some assoc collection string') + 'expectedValue' => new StringSetting($name, 'some assoc collection string') ]; yield 'list query' => [ @@ -155,8 +153,8 @@ public function proxyTestDataProvider(): \Generator 'serviceMethod' => 'getSettingsList', 'params' => ['awesomeTheme'], 'expectedValue' => [ - new SettingType($settingNameID, FieldType::NUMBER), - new SettingType($settingNameID, FieldType::NUMBER), + new SettingType($name, FieldType::NUMBER), + new SettingType($name, FieldType::NUMBER), ] ]; } diff --git a/tests/Unit/DataType/BooleanSettingTest.php b/tests/Unit/DataType/BooleanSettingTest.php index b63cf06..4627dc1 100644 --- a/tests/Unit/DataType/BooleanSettingTest.php +++ b/tests/Unit/DataType/BooleanSettingTest.php @@ -11,7 +11,6 @@ use OxidEsales\GraphQL\ConfigurationAccess\Setting\DataType\BooleanSetting; use PHPUnit\Framework\TestCase; -use TheCodingMachine\GraphQLite\Types\ID; /** * @covers \OxidEsales\GraphQL\ConfigurationAccess\Setting\DataType\BooleanSetting @@ -19,7 +18,7 @@ class BooleanSettingTest extends TestCase { /** @dataProvider booleanSettingDataProvider */ - public function testBooleanSetting(ID $name, bool $value): void + public function testBooleanSetting(string $name, bool $value): void { $sut = new BooleanSetting($name, $value); @@ -29,7 +28,7 @@ public function testBooleanSetting(ID $name, bool $value): void public function booleanSettingDataProvider(): \Generator { - yield [new ID('boolean positive setting'), true]; - yield [new ID('boolean negative setting'), false]; + yield [uniqid(), true]; + yield [uniqid(), false]; } } diff --git a/tests/Unit/DataType/FloatSettingTest.php b/tests/Unit/DataType/FloatSettingTest.php index f9cac7c..083535a 100644 --- a/tests/Unit/DataType/FloatSettingTest.php +++ b/tests/Unit/DataType/FloatSettingTest.php @@ -11,7 +11,6 @@ use OxidEsales\GraphQL\ConfigurationAccess\Setting\DataType\FloatSetting; use PHPUnit\Framework\TestCase; -use TheCodingMachine\GraphQLite\Types\ID; /** * @covers \OxidEsales\GraphQL\ConfigurationAccess\Setting\DataType\FloatSetting @@ -19,7 +18,7 @@ class FloatSettingTest extends TestCase { /** @dataProvider floatSettingDataProvider */ - public function testFloatSetting(ID $name, float $value): void + public function testFloatSetting(string $name, float $value): void { $sut = new FloatSetting($name, $value); @@ -29,7 +28,7 @@ public function testFloatSetting(ID $name, float $value): void public function floatSettingDataProvider(): \Generator { - yield "random float" => [new ID(uniqid()), rand(1, 100) / 10]; - yield "random integer" => [new ID(uniqid()), rand(1, 100)]; + yield "random float" => [uniqid(), rand(1, 100) / 10]; + yield "random integer" => [uniqid(), rand(1, 100)]; } } diff --git a/tests/Unit/DataType/IntegerSettingTest.php b/tests/Unit/DataType/IntegerSettingTest.php index ac175b4..a796bea 100644 --- a/tests/Unit/DataType/IntegerSettingTest.php +++ b/tests/Unit/DataType/IntegerSettingTest.php @@ -11,7 +11,6 @@ use OxidEsales\GraphQL\ConfigurationAccess\Setting\DataType\IntegerSetting; use PHPUnit\Framework\TestCase; -use TheCodingMachine\GraphQLite\Types\ID; /** * @covers \OxidEsales\GraphQL\ConfigurationAccess\Setting\DataType\IntegerSetting @@ -19,7 +18,7 @@ class IntegerSettingTest extends TestCase { /** @dataProvider integerSettingDataProvider */ - public function testIntegerSetting(ID $name, int $value): void + public function testIntegerSetting(string $name, int $value): void { $sut = new IntegerSetting($name, $value); @@ -29,6 +28,6 @@ public function testIntegerSetting(ID $name, int $value): void public function integerSettingDataProvider(): \Generator { - yield "random integer" => [new ID(uniqid()), rand(1, 100)]; + yield "random integer" => [uniqid(), rand(1, 100)]; } } diff --git a/tests/Unit/DataType/SettingTypeTest.php b/tests/Unit/DataType/SettingTypeTest.php index 8ff2e73..5f7e7e1 100644 --- a/tests/Unit/DataType/SettingTypeTest.php +++ b/tests/Unit/DataType/SettingTypeTest.php @@ -12,7 +12,6 @@ use OxidEsales\GraphQL\ConfigurationAccess\Setting\DataType\SettingType; use OxidEsales\GraphQL\ConfigurationAccess\Setting\Enum\FieldType; use PHPUnit\Framework\TestCase; -use TheCodingMachine\GraphQLite\Types\ID; /** * @covers \OxidEsales\GraphQL\ConfigurationAccess\Setting\DataType\SettingType @@ -21,7 +20,7 @@ class SettingTypeTest extends TestCase { public function testGetters(): void { - $settingIdentifier = new ID('someSettingName'); + $settingIdentifier = 'someSettingName'; $settingType = 'someRandomType'; $sut = new SettingType( @@ -37,7 +36,7 @@ public function testGetters(): void public function testIsSupported(string $settingType, bool $expectation): void { $sut = new SettingType( - new ID('someSettingName'), + 'someSettingName', $settingType ); diff --git a/tests/Unit/DataType/StringSettingTest.php b/tests/Unit/DataType/StringSettingTest.php index 4ea5618..3440108 100644 --- a/tests/Unit/DataType/StringSettingTest.php +++ b/tests/Unit/DataType/StringSettingTest.php @@ -11,7 +11,6 @@ use OxidEsales\GraphQL\ConfigurationAccess\Setting\DataType\StringSetting; use PHPUnit\Framework\TestCase; -use TheCodingMachine\GraphQLite\Types\ID; /** * @covers \OxidEsales\GraphQL\ConfigurationAccess\Setting\DataType\StringSetting @@ -19,7 +18,7 @@ class StringSettingTest extends TestCase { /** @dataProvider stringSettingDataProvider */ - public function testStringSetting(ID $name, $value): void + public function testStringSetting(string $name, $value): void { $sut = new StringSetting($name, $value); @@ -29,6 +28,6 @@ public function testStringSetting(ID $name, $value): void public function stringSettingDataProvider(): \Generator { - yield "random strings" => [new ID(uniqid()), uniqid()]; + yield "random strings" => [uniqid(), uniqid()]; } } diff --git a/tests/Unit/Service/ModuleSettingServiceTest.php b/tests/Unit/Service/ModuleSettingServiceTest.php index d5d1978..2a61202 100644 --- a/tests/Unit/Service/ModuleSettingServiceTest.php +++ b/tests/Unit/Service/ModuleSettingServiceTest.php @@ -19,7 +19,6 @@ use OxidEsales\GraphQL\ConfigurationAccess\Setting\Service\JsonServiceInterface; use OxidEsales\GraphQL\ConfigurationAccess\Setting\Service\ModuleSettingService; use OxidEsales\GraphQL\ConfigurationAccess\Tests\Unit\UnitTestCase; -use TheCodingMachine\GraphQLite\Types\ID; /** * @covers \OxidEsales\GraphQL\ConfigurationAccess\Setting\Service\ModuleSettingService @@ -40,9 +39,8 @@ public function testGetModuleSettingInteger(): void $sut = $this->getSut($repository); - $nameID = new ID($name); $this->assertEquals( - new IntegerSetting($nameID, $repositoryResponse), + new IntegerSetting($name, $repositoryResponse), $sut->getIntegerSetting($name, $moduleId) ); } @@ -61,9 +59,8 @@ public function testGetModuleSettingFloat(): void $sut = $this->getSut($repository); - $nameID = new ID($name); $this->assertEquals( - new FloatSetting($nameID, $repositoryResponse), + new FloatSetting($name, $repositoryResponse), $sut->getFloatSetting($name, $moduleId) ); } @@ -82,9 +79,8 @@ public function testGetModuleSettingBoolean(): void $sut = $this->getSut($repository); - $nameID = new ID($name); $this->assertEquals( - new BooleanSetting($nameID, $repositoryResponse), + new BooleanSetting($name, $repositoryResponse), $sut->getBooleanSetting($name, $moduleId) ); } @@ -103,9 +99,8 @@ public function testGetModuleSettingString(): void $sut = $this->getSut($repository); - $nameID = new ID($name); $this->assertEquals( - new StringSetting($nameID, $repositoryResponse), + new StringSetting($name, $repositoryResponse), $sut->getStringSetting($name, $moduleId) ); } @@ -133,9 +128,8 @@ public function testGetModuleSettingCollection(): void jsonService: $encoder ); - $nameID = new ID($name); $this->assertEquals( - new StringSetting($nameID, $encoderResponse), + new StringSetting($name, $encoderResponse), $sut->getCollectionSetting($name, $moduleId) ); } @@ -161,10 +155,9 @@ public function testChangeModuleSettingInteger(): void repository: $repository ); - $nameID = new ID($name); $setting = $sut->changeIntegerSetting($name, $callValue, $moduleId); - $this->assertEquals($nameID, $setting->getName()); + $this->assertEquals($name, $setting->getName()); $this->assertSame($repositoryValue, $setting->getValue()); } @@ -189,10 +182,9 @@ public function testChangeModuleSettingFloat(): void repository: $repository ); - $nameID = new ID($name); $setting = $sut->changeFloatSetting($name, $callValue, $moduleId); - $this->assertEquals($nameID, $setting->getName()); + $this->assertEquals($name, $setting->getName()); $this->assertSame($repositoryValue, $setting->getValue()); } @@ -217,10 +209,9 @@ public function testChangeModuleSettingBoolean(): void repository: $repository ); - $nameID = new ID($name); $setting = $sut->changeBooleanSetting($name, $callValue, $moduleId); - $this->assertEquals($nameID, $setting->getName()); + $this->assertEquals($name, $setting->getName()); $this->assertSame($repositoryValue, $setting->getValue()); } @@ -245,10 +236,9 @@ public function testChangeModuleSettingString(): void repository: $repository ); - $nameID = new ID($name); $setting = $sut->changeStringSetting($name, $callValue, $moduleId); - $this->assertEquals($nameID, $setting->getName()); + $this->assertEquals($name, $setting->getName()); $this->assertSame($repositoryValue, $setting->getValue()); } @@ -283,10 +273,9 @@ public function testChangeModuleSettingCollection(): void jsonService: $encoder, ); - $nameID = new ID($name); $setting = $sut->changeCollectionSetting($name, $callValue, $moduleId); - $this->assertEquals($nameID, $setting->getName()); + $this->assertEquals($name, $setting->getName()); $this->assertSame($encoderResponse, $setting->getValue()); } diff --git a/tests/Unit/Service/ShopSettingServiceTest.php b/tests/Unit/Service/ShopSettingServiceTest.php index 75990ca..81c9e6f 100644 --- a/tests/Unit/Service/ShopSettingServiceTest.php +++ b/tests/Unit/Service/ShopSettingServiceTest.php @@ -18,7 +18,6 @@ use OxidEsales\GraphQL\ConfigurationAccess\Setting\Service\JsonServiceInterface; use OxidEsales\GraphQL\ConfigurationAccess\Setting\Service\ShopSettingService; use OxidEsales\GraphQL\ConfigurationAccess\Tests\Unit\UnitTestCase; -use TheCodingMachine\GraphQLite\Types\ID; /** * @covers \OxidEsales\GraphQL\ConfigurationAccess\Setting\Service\ShopSettingService @@ -32,56 +31,56 @@ public function testGetNotEncodableShopSetting( string $serviceMethod, mixed $expectedResult ): void { - $nameID = new ID('settingName'); + $name = 'settingName'; $sut = $this->getSut( shopSettingRepository: $this->getShopRepositorySettingGetterMock( $repositoryMethod, - $nameID, + $name, $repositoryResult ) ); - $this->assertEquals($expectedResult, $sut->$serviceMethod((string)$nameID)); + $this->assertEquals($expectedResult, $sut->$serviceMethod($name)); } public function getNotEncodableShopSettingDataProvider(): \Generator { - $nameID = new ID('settingName'); + $name = 'settingName'; yield 'getIntegerSetting' => [ 'repositoryMethod' => 'getInteger', 'repositoryResult' => 123, 'serviceMethod' => 'getIntegerSetting', - 'expectedResult' => new IntegerSetting($nameID, 123) + 'expectedResult' => new IntegerSetting($name, 123) ]; yield 'getFloatSetting' => [ 'repositoryMethod' => 'getFloat', 'repositoryResult' => 1.23, 'serviceMethod' => 'getFloatSetting', - 'expectedResult' => new FloatSetting($nameID, 1.23) + 'expectedResult' => new FloatSetting($name, 1.23) ]; yield 'getBooleanSetting' => [ 'repositoryMethod' => 'getBoolean', 'repositoryResult' => false, 'serviceMethod' => 'getBooleanSetting', - 'expectedResult' => new BooleanSetting($nameID, false) + 'expectedResult' => new BooleanSetting($name, false) ]; yield 'getStringSetting' => [ 'repositoryMethod' => 'getString', 'repositoryResult' => 'default', 'serviceMethod' => 'getStringSetting', - 'expectedResult' => new StringSetting($nameID, 'default') + 'expectedResult' => new StringSetting($name, 'default') ]; yield 'getSelectSetting' => [ 'repositoryMethod' => 'getSelect', 'repositoryResult' => 'selectResult', 'serviceMethod' => 'getSelectSetting', - 'expectedResult' => new StringSetting($nameID, 'selectResult') + 'expectedResult' => new StringSetting($name, 'selectResult') ]; } @@ -91,21 +90,21 @@ public function testGetEncodableShopSetting( mixed $repositoryResult, string $serviceMethod ): void { - $nameID = new ID('settingName'); + $name = 'settingName'; $encodingResult = 'someEncodedResult'; $sut = $this->getSut( shopSettingRepository: $this->getShopRepositorySettingGetterMock( $repositoryMethod, - $nameID, + $name, $repositoryResult ), jsonService: $this->getJsonEncodeServiceMock($repositoryResult, $encodingResult), ); $this->assertEquals( - new StringSetting($nameID, $encodingResult), - $sut->$serviceMethod((string)$nameID) + new StringSetting($name, $encodingResult), + $sut->$serviceMethod($name) ); } @@ -126,13 +125,13 @@ public function getEncodableShopSettingDataProvider(): \Generator private function getShopRepositorySettingGetterMock( string $repositoryMethod, - ID $nameID, + string $name, $repositoryResult ): ShopSettingRepositoryInterface { $repository = $this->createMock(ShopSettingRepositoryInterface::class); $repository->expects($this->once()) ->method($repositoryMethod) - ->with($nameID) + ->with($name) ->willReturn($repositoryResult); return $repository; } diff --git a/tests/Unit/Service/ThemeSettingServiceTest.php b/tests/Unit/Service/ThemeSettingServiceTest.php index 2c0dca6..9880411 100644 --- a/tests/Unit/Service/ThemeSettingServiceTest.php +++ b/tests/Unit/Service/ThemeSettingServiceTest.php @@ -20,7 +20,6 @@ use OxidEsales\GraphQL\ConfigurationAccess\Setting\Service\ThemeSettingService; use OxidEsales\GraphQL\ConfigurationAccess\Tests\Unit\UnitTestCase; use PHPUnit\Framework\MockObject\MockObject; -use TheCodingMachine\GraphQLite\Types\ID; /** * @covers \OxidEsales\GraphQL\ConfigurationAccess\Setting\Service\ThemeSettingService @@ -43,7 +42,7 @@ public function testGetThemeSettingInteger(): void ); $this->assertEquals( - new IntegerSetting(new ID($name), $repositoryResult), + new IntegerSetting($name, $repositoryResult), $sut->getIntegerSetting($name, $themeId) ); } @@ -64,7 +63,7 @@ public function testGetThemeSettingFloat(): void ); $this->assertEquals( - new FloatSetting(new ID($name), $repositoryResult), + new FloatSetting($name, $repositoryResult), $sut->getFloatSetting($name, $themeId) ); } @@ -85,7 +84,7 @@ public function testGetThemeSettingBoolean(): void ); $this->assertEquals( - new BooleanSetting(new ID($name), $repositoryResult), + new BooleanSetting($name, $repositoryResult), $sut->getBooleanSetting($name, $themeId) ); } @@ -106,7 +105,7 @@ public function testGetThemeSettingString(): void ); $this->assertEquals( - new StringSetting(new ID($name), $repositoryResult), + new StringSetting($name, $repositoryResult), $sut->getStringSetting($name, $themeId) ); } @@ -127,7 +126,7 @@ public function testGetThemeSettingSelect(): void ); $this->assertEquals( - new StringSetting(new ID($name), $repositoryResult), + new StringSetting($name, $repositoryResult), $sut->getSelectSetting($name, $themeId) ); } @@ -151,7 +150,7 @@ public function testGetThemeSettingCollection(): void ); $this->assertEquals( - new StringSetting(new ID($name), $collectionEncodingResult), + new StringSetting($name, $collectionEncodingResult), $sut->getCollectionSetting($name, $themeId) ); } @@ -175,7 +174,7 @@ public function testGetThemeSettingAssocCollectionGetsAndEncodesRepositoryResult ); $this->assertEquals( - new StringSetting(new ID($name), $collectionEncodingResult), + new StringSetting($name, $collectionEncodingResult), $sut->getAssocCollectionSetting($name, $themeId) ); } @@ -233,7 +232,7 @@ public function testChangeThemeSettingInteger(): void $settingService = $this->getSut(themeSettingRepository: $repository); $integerSetting = $settingService->changeIntegerSetting($name, $setterValue, $themeID); - $this->assertEquals(new ID($name), $integerSetting->getName()); + $this->assertEquals($name, $integerSetting->getName()); $this->assertSame($getterValue, $integerSetting->getValue()); } @@ -257,7 +256,7 @@ public function testChangeThemeSettingFloat(): void $settingService = $this->getSut(themeSettingRepository: $repository); $floatSetting = $settingService->changeFloatSetting($name, $setterValue, $themeID); - $this->assertEquals(new ID($name), $floatSetting->getName()); + $this->assertEquals($name, $floatSetting->getName()); $this->assertSame($getterValue, $floatSetting->getValue()); } @@ -282,7 +281,7 @@ public function testChangeThemeSettingBoolean(): void $booleanSetting = $settingService->changeBooleanSetting($name, $setterValue, $themeID); - $this->assertEquals(new ID($name), $booleanSetting->getName()); + $this->assertEquals($name, $booleanSetting->getName()); $this->assertSame($getterValue, $booleanSetting->getValue()); } @@ -307,7 +306,7 @@ public function testChangeThemeSettingString(): void $stringSetting = $settingService->changeStringSetting($name, $setterValue, $themeID); - $this->assertEquals(new ID($name), $stringSetting->getName()); + $this->assertEquals($name, $stringSetting->getName()); $this->assertSame($getterValue, $stringSetting->getValue()); } @@ -331,7 +330,7 @@ public function testChangeThemeSettingSelect(): void $selectSetting = $settingService->changeSelectSetting($name, $setterValue, $themeID); - $this->assertEquals(new ID($name), $selectSetting->getName()); + $this->assertEquals($name, $selectSetting->getName()); $this->assertSame($getterValue, $selectSetting->getValue()); } @@ -400,7 +399,7 @@ public function testChangeThemeSettingCollection(): void $settingService = $this->getSut(themeSettingRepository: $repository, jsonService: $jsonService); $collectionSetting = $settingService->changeCollectionSetting($name, $setterEncodedCollection, $themeID); - $this->assertEquals(new ID($name), $collectionSetting->getName()); + $this->assertEquals($name, $collectionSetting->getName()); $this->assertSame($getterEncodedCollection, $collectionSetting->getValue()); } @@ -427,7 +426,7 @@ public function testChangeThemeSettingAssocCollection(): void $settingService = $this->getSut(themeSettingRepository: $repository, jsonService: $jsonService); $collectionSetting = $settingService->changeAssocCollectionSetting($name, $setterEncodedCollection, $themeID); - $this->assertEquals(new ID($name), $collectionSetting->getName()); + $this->assertEquals($name, $collectionSetting->getName()); $this->assertSame($getterEncodedCollection, $collectionSetting->getValue()); } diff --git a/tests/Unit/UnitTestCase.php b/tests/Unit/UnitTestCase.php index 13f0a2a..e07125a 100644 --- a/tests/Unit/UnitTestCase.php +++ b/tests/Unit/UnitTestCase.php @@ -27,9 +27,9 @@ class UnitTestCase extends TestCase */ protected function getSettingTypeList(): array { - $intSetting = new SettingType(new ID('intSetting'), FieldType::NUMBER); - $stringSetting = new SettingType(new ID('stringSetting'), FieldType::STRING); - $arraySetting = new SettingType(new ID('arraySetting'), FieldType::ARRAY); + $intSetting = new SettingType('intSetting', FieldType::NUMBER); + $stringSetting = new SettingType('stringSetting', FieldType::STRING); + $arraySetting = new SettingType('arraySetting', FieldType::ARRAY); return [$intSetting, $stringSetting, $arraySetting]; }