public function testSaveLabel() { $attributeId = 4354; $select = $this->getMockBuilder(Select::class)->disableOriginalConstructor()->getMock(); $this->connection->expects($this->once())->method('select')->willReturn($select); $select->expects($this->once())->method('from')->willReturnSelf(); $select->expects($this->at(1))->method('where')->willReturnSelf(); $select->expects($this->at(2))->method('where')->willReturnSelf(); $this->connection->expects($this->once())->method('fetchOne')->with($select, ['product_super_attribute_id' => $attributeId, 'store_id' => \Magento\Store\Model\Store::DEFAULT_STORE_ID])->willReturn(0); $this->connection->expects($this->once())->method('insertOnDuplicate')->with('catalog_product_super_attribute_label', ['product_super_attribute_id' => $attributeId, 'use_default' => 0, 'store_id' => 0, 'value' => 'test']); $attributeMode = $this->getMockBuilder(AttributeModel::class)->setMethods(['getId', 'getUseDefault', 'getLabel'])->disableOriginalConstructor()->getMock(); $attributeMode->expects($this->any())->method('getId')->willReturn($attributeId); $attributeMode->expects($this->any())->method('getUseDefault')->willReturn(0); $attributeMode->expects($this->any())->method('getLabel')->willReturn('test'); $this->assertEquals($this->attribute, $this->attribute->saveLabel($attributeMode)); }
/** * {@inheritdoc} */ public function delete(OptionInterface $option) { $product = $this->getProductById($option->getProductId()); try { $this->configurableTypeResource->saveProducts($product, []); } catch (\Exception $exception) { throw new StateException(__('Cannot delete variations from product: %1', $option->getProductId())); } try { $this->optionResource->delete($option); } catch (\Exception $exception) { throw new StateException(__('Cannot delete option with id: %1', $option->getId())); } return true; }