Skip to content

Commit

Permalink
Fix adding an option with label '0'
Browse files Browse the repository at this point in the history
Apply suggestions from code review
  • Loading branch information
ihor-sviziev authored Nov 12, 2021
1 parent e3d09f7 commit 2a96c5e
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public function add($entityType, $attributeCode, $option)
{
$attribute = $this->loadAttribute($entityType, (string)$attributeCode);

$label = trim((string) $option->getLabel());
$label = trim((string)$option->getLabel());
if ($label === '') {
throw new InputException(__('The attribute option label is empty. Enter the value and try again.'));
}
Expand Down Expand Up @@ -93,7 +93,7 @@ public function update(
if (empty($optionId)) {
throw new InputException(__('The option id is empty. Enter the value and try again.'));
}
$label = trim((string) $option->getLabel());
$label = trim((string)$option->getLabel());
if ($label === '') {
throw new InputException(__('The attribute option label is empty. Enter the value and try again.'));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,10 @@ protected function setUp(): void
/**
* Test to add attribute option
*
* @param string $label
* @dataProvider optionLabelDataProvider
*/
public function testAdd($label)
public function testAdd(string $label): void
{
$entityType = 42;
$storeId = 4;
Expand Down Expand Up @@ -232,9 +233,10 @@ public function testAddWithCannotSaveException()
/**
* Test to update attribute option
*
* @param string $label
* @dataProvider optionLabelDataProvider
*/
public function testUpdate($label)
public function testUpdate(string $label): void
{
$entityType = Product::ENTITY;
$storeId = 4;
Expand Down

0 comments on commit 2a96c5e

Please sign in to comment.