Skip to content

Commit 5eef1d9

Browse files
author
Stanislav Idolov
committed
#12920: Fixed review issues
1 parent 294e200 commit 5eef1d9

File tree

6 files changed

+12
-9
lines changed

6 files changed

+12
-9
lines changed

app/code/Magento/Catalog/Api/ProductAttributeOptionManagementInterface.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ public function getItems($attributeCode);
2929
* @param \Magento\Eav\Api\Data\AttributeOptionInterface $option
3030
* @throws \Magento\Framework\Exception\StateException
3131
* @throws \Magento\Framework\Exception\InputException
32-
* @return \Magento\Eav\Api\Data\AttributeOptionInterface
32+
* @return string
3333
*/
3434
public function add($attributeCode, $option);
3535

app/code/Magento/Eav/Api/AttributeOptionManagementInterface.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ interface AttributeOptionManagementInterface
2020
* @param \Magento\Eav\Api\Data\AttributeOptionInterface $option
2121
* @throws \Magento\Framework\Exception\StateException
2222
* @throws \Magento\Framework\Exception\InputException
23-
* @return \Magento\Eav\Api\Data\AttributeOptionInterface
23+
* @return string
2424
*/
2525
public function add($entityType, $attributeCode, $option);
2626

app/code/Magento/Eav/Model/Entity/Attribute/OptionManagement.php

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ public function add($entityType, $attributeCode, $option)
7575
throw new StateException(__('The "%1" attribute can\'t be saved.', $attributeCode));
7676
}
7777

78-
return $option;
78+
return $this->getOptionId($option);
7979
}
8080

8181
/**
@@ -151,7 +151,7 @@ protected function validateOption($attribute, $optionId)
151151
* @param \Magento\Eav\Api\Data\AttributeOptionInterface $option
152152
* @return string
153153
*/
154-
private function getOptionId($option)
154+
private function getOptionId(\Magento\Eav\Api\Data\AttributeOptionInterface $option) : string
155155
{
156156
return $option->getValue() ?: 'new_option';
157157
}
@@ -162,8 +162,11 @@ private function getOptionId($option)
162162
* @param string $optionLabel
163163
* @return void
164164
*/
165-
protected function setOptionValue($option, $attribute, $optionLabel)
166-
{
165+
private function setOptionValue(
166+
\Magento\Eav\Api\Data\AttributeOptionInterface $option,
167+
\Magento\Eav\Api\Data\AttributeInterface $attribute,
168+
string $optionLabel
169+
) {
167170
$optionId = $attribute->getSource()->getOptionId($optionLabel);
168171
if ($optionId) {
169172
$option->setValue($attribute->getSource()->getOptionId($optionId));

app/code/Magento/Eav/Test/Unit/Model/Entity/Attribute/OptionManagementTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ public function testAdd()
8181
$attributeMock->expects($this->once())->method('setDefault')->with(['new_option']);
8282
$attributeMock->expects($this->once())->method('setOption')->with($option);
8383
$this->resourceModelMock->expects($this->once())->method('save')->with($attributeMock);
84-
$this->assertEquals($optionMock, $this->model->add($entityType, $attributeCode, $optionMock));
84+
$this->assertEquals('new_option', $this->model->add($entityType, $attributeCode, $optionMock));
8585
}
8686

8787
/**

dev/tests/api-functional/testsuite/Magento/Catalog/Api/ProductAttributeOptionManagementInterfaceTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ public function testAdd($optionData)
7474
]
7575
);
7676

77-
$this->assertNotNull($response[AttributeOptionInterface::VALUE]);
77+
$this->assertNotNull($response);
7878
$updatedData = $this->getAttributeOptions($testAttributeCode);
7979
$lastOption = array_pop($updatedData);
8080
$this->assertEquals(

dev/tests/api-functional/testsuite/Magento/Catalog/Api/ProductSwatchAttributeOptionManagementInterfaceTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ public function testAdd($optionData)
4242
]
4343
);
4444

45-
$this->assertNotNull($response[AttributeOptionInterface::VALUE]);
45+
$this->assertNotNull($response);
4646
$updatedData = $this->getAttributeOptions($testAttributeCode);
4747
$lastOption = array_pop($updatedData);
4848
$this->assertEquals(

0 commit comments

Comments
 (0)