Skip to content

Commit

Permalink
OXDEV-7458 Use string in place of ID in shop setting controller input
Browse files Browse the repository at this point in the history
Signed-off-by: Anton Fedurtsya <[email protected]>
  • Loading branch information
Sieg committed Nov 21, 2023
1 parent d6c4a2b commit 706b1e0
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 14 deletions.
21 changes: 14 additions & 7 deletions src/Setting/Controller/ShopSettingController.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
<?php

/**
* Copyright © OXID eSales AG. All rights reserved.
* See LICENSE file for license details.
*/

declare(strict_types=1);

namespace OxidEsales\GraphQL\ConfigurationAccess\Setting\Controller;

use OxidEsales\GraphQL\ConfigurationAccess\Setting\DataType\BooleanSetting;
Expand All @@ -26,7 +33,7 @@ public function __construct(
#[Logged]
#[HideIfUnauthorized]
#[Right('CHANGE_CONFIGURATION')]
public function getShopSettingInteger(ID $name): IntegerSetting
public function getShopSettingInteger(string $name): IntegerSetting
{
return $this->shopSettingService->getIntegerSetting($name);
}
Expand All @@ -35,7 +42,7 @@ public function getShopSettingInteger(ID $name): IntegerSetting
#[Logged]
#[HideIfUnauthorized]
#[Right('CHANGE_CONFIGURATION')]
public function getShopSettingFloat(ID $name): FloatSetting
public function getShopSettingFloat(string $name): FloatSetting
{
return $this->shopSettingService->getFloatSetting($name);
}
Expand All @@ -44,7 +51,7 @@ public function getShopSettingFloat(ID $name): FloatSetting
#[Logged]
#[HideIfUnauthorized]
#[Right('CHANGE_CONFIGURATION')]
public function getShopSettingBoolean(ID $name): BooleanSetting
public function getShopSettingBoolean(string $name): BooleanSetting
{
return $this->shopSettingService->getBooleanSetting($name);
}
Expand All @@ -53,7 +60,7 @@ public function getShopSettingBoolean(ID $name): BooleanSetting
#[Logged]
#[HideIfUnauthorized]
#[Right('CHANGE_CONFIGURATION')]
public function getShopSettingString(ID $name): StringSetting
public function getShopSettingString(string $name): StringSetting
{
return $this->shopSettingService->getStringSetting($name);
}
Expand All @@ -62,7 +69,7 @@ public function getShopSettingString(ID $name): StringSetting
#[Logged]
#[HideIfUnauthorized]
#[Right('CHANGE_CONFIGURATION')]
public function getShopSettingSelect(ID $name): StringSetting
public function getShopSettingSelect(string $name): StringSetting
{
return $this->shopSettingService->getSelectSetting($name);
}
Expand All @@ -71,7 +78,7 @@ public function getShopSettingSelect(ID $name): StringSetting
#[Logged]
#[HideIfUnauthorized]
#[Right('CHANGE_CONFIGURATION')]
public function getShopSettingCollection(ID $name): StringSetting
public function getShopSettingCollection(string $name): StringSetting
{
return $this->shopSettingService->getCollectionSetting($name);
}
Expand All @@ -80,7 +87,7 @@ public function getShopSettingCollection(ID $name): StringSetting
#[Logged]
#[HideIfUnauthorized]
#[Right('CHANGE_CONFIGURATION')]
public function getShopSettingAssocCollection(ID $name): StringSetting
public function getShopSettingAssocCollection(string $name): StringSetting
{
return $this->shopSettingService->getAssocCollectionSetting($name);
}
Expand Down
14 changes: 7 additions & 7 deletions tests/Unit/Controller/ShopSettingControllerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,49 +48,49 @@ public function proxyTestDataProvider(): \Generator
yield 'getter integer' => [
'controllerMethod' => 'getShopSettingInteger',
'serviceMethod' => 'getIntegerSetting',
'params' => [$settingNameID],
'params' => [$settingName],
'expectedValue' => new IntegerSetting($settingNameID, 123)
];

yield 'getter float' => [
'controllerMethod' => 'getShopSettingFloat',
'serviceMethod' => 'getFloatSetting',
'params' => [$settingNameID],
'params' => [$settingName],
'expectedValue' => new FloatSetting($settingNameID, 1.23)
];

yield 'getter bool' => [
'controllerMethod' => 'getShopSettingBoolean',
'serviceMethod' => 'getBooleanSetting',
'params' => [$settingNameID],
'params' => [$settingName],
'expectedValue' => new BooleanSetting($settingNameID, false)
];

yield 'getter string' => [
'controllerMethod' => 'getShopSettingString',
'serviceMethod' => 'getStringSetting',
'params' => [$settingNameID],
'params' => [$settingName],
'expectedValue' => new StringSetting($settingNameID, 'default')
];

yield 'getter select' => [
'controllerMethod' => 'getShopSettingSelect',
'serviceMethod' => 'getSelectSetting',
'params' => [$settingNameID],
'params' => [$settingName],
'expectedValue' => new StringSetting($settingNameID, 'some select setting value')
];

yield 'getter collection' => [
'controllerMethod' => 'getShopSettingCollection',
'serviceMethod' => 'getCollectionSetting',
'params' => [$settingNameID],
'params' => [$settingName],
'expectedValue' => new StringSetting($settingNameID, 'some collection string example')
];

yield 'getter associative collection' => [
'controllerMethod' => 'getShopSettingAssocCollection',
'serviceMethod' => 'getAssocCollectionSetting',
'params' => [$settingNameID],
'params' => [$settingName],
'expectedValue' => new StringSetting($settingNameID, 'some associative collection string example')
];

Expand Down

0 comments on commit 706b1e0

Please sign in to comment.