/** * @expectedException \Magento\Framework\Exception\InputException * @expectedExceptionMessage Products "5" and "4" have the same set of attribute values. */ public function testAroundSaveWithLinksWithDuplicateAttributes() { $links = [4, 5]; $attributeCode = 'color'; $attributeId = 23; $this->option->expects(static::once())->method('getAttributeId')->willReturn($attributeId); $this->product->expects(static::once())->method('getTypeId')->willReturn(Configurable::TYPE_CODE); $this->result->expects(static::once())->method('getExtensionAttributes')->willReturn($this->extensionAttributes); $this->extensionAttributes->expects(static::once())->method('getConfigurableProductOptions')->willReturn([$this->option]); $this->extensionAttributes->expects(static::once())->method('getConfigurableProductLinks')->willReturn($links); $this->productAttributeRepository->expects(static::once())->method('get')->willReturn($this->eavAttribute); $this->eavAttribute->expects(static::once())->method('getAttributeCode')->willReturn($attributeCode); $product = $this->getMockBuilder(Product::class)->disableOriginalConstructor()->setMethods(['load', 'getData', '__wakeup'])->getMock(); $this->productFactory->expects(static::exactly(2))->method('create')->willReturn($product); $product->expects(static::exactly(2))->method('load')->willReturnSelf(); $product->expects(static::exactly(4))->method('getData')->with($attributeCode)->willReturn($attributeId); $this->plugin->aroundSave($this->productRepository, $this->closure, $this->product); }