/** * @expectedException \Magento\Framework\Exception\InputException * @expectedExceptionMessage Invalid option id */ public function testDeleteWithInvalidOption() { $attributeCode = 'atrCde'; $optionId = ''; $this->eavOptionManagementMock->expects($this->never())->method('delete'); $this->model->delete($attributeCode, $optionId); }
protected function updateAll($updateData) { $result = 0; foreach ($updateData as $attributeUpdate) { if ($attributeUpdate['attribute_type'] == 'product') { if ($attributeUpdate['status'] == self::ADD_ATTRIBUTE_OPTION) { $optionToAdd = $this->optionDataFactory->create(); $optionToAdd->setLabel($attributeUpdate['value'])->setSortOrder(0)->setIsDefault(0); try { $this->attributeOptionManagement->add($attributeUpdate['attribute_code'], $optionToAdd); $result++; } catch (\Exception $e) { $this->shipperLogger->postInfo('Shipperhq_Shipper', 'Unable to add attribute option', 'Error: ' . $e->getMessage()); $result = false; } } else { if ($attributeUpdate['status'] == self::AUTO_REMOVE_ATTRIBUTE_OPTION) { try { $this->attributeOptionManagement->delete($attributeUpdate['attribute_code'], $attributeUpdate['option_id']); $result++; } catch (\Exception $e) { $this->shipperLogger->postInfo('Shipperhq_Shipper', 'Unable to remove attribute option', 'Error: ' . $e->getMessage()); $result = false; } } } } elseif ($attributeUpdate['attribute_type'] == 'global_setting') { $this->carrierConfigHandler->saveConfig('carriers/shipper/' . $attributeUpdate['attribute_code'], $attributeUpdate['value']); } } if ($result >= 0) { $this->checkSynchStatus(true); } return $result; }