Skip to content

Commit 2a96c5e

Browse files
authored
Fix adding an option with label '0'
Apply suggestions from code review
1 parent e3d09f7 commit 2a96c5e

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ public function add($entityType, $attributeCode, $option)
6060
{
6161
$attribute = $this->loadAttribute($entityType, (string)$attributeCode);
6262

63-
$label = trim((string) $option->getLabel());
63+
$label = trim((string)$option->getLabel());
6464
if ($label === '') {
6565
throw new InputException(__('The attribute option label is empty. Enter the value and try again.'));
6666
}
@@ -93,7 +93,7 @@ public function update(
9393
if (empty($optionId)) {
9494
throw new InputException(__('The option id is empty. Enter the value and try again.'));
9595
}
96-
$label = trim((string) $option->getLabel());
96+
$label = trim((string)$option->getLabel());
9797
if ($label === '') {
9898
throw new InputException(__('The attribute option label is empty. Enter the value and try again.'));
9999
}

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

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,9 +61,10 @@ protected function setUp(): void
6161
/**
6262
* Test to add attribute option
6363
*
64+
* @param string $label
6465
* @dataProvider optionLabelDataProvider
6566
*/
66-
public function testAdd($label)
67+
public function testAdd(string $label): void
6768
{
6869
$entityType = 42;
6970
$storeId = 4;
@@ -232,9 +233,10 @@ public function testAddWithCannotSaveException()
232233
/**
233234
* Test to update attribute option
234235
*
236+
* @param string $label
235237
* @dataProvider optionLabelDataProvider
236238
*/
237-
public function testUpdate($label)
239+
public function testUpdate(string $label): void
238240
{
239241
$entityType = Product::ENTITY;
240242
$storeId = 4;

0 commit comments

Comments
 (0)