/** * @expectedException \Magento\Framework\Exception\NoSuchEntityException */ public function testRemoveChildInvalidChildSku() { $this->productRepositoryMock->expects($this->any())->method('get')->will($this->returnValue($this->product)); $productSku = 'productSku'; $optionId = 1; $childSku = 'childSku'; $this->product->expects($this->any())->method('getTypeId')->will($this->returnValue(\Magento\Catalog\Model\Product\Type::TYPE_BUNDLE)); $this->getOptions(); $selection = $this->getMockBuilder('\\Magento\\Bundle\\Model\\Selection')->setMethods(['getSku', 'getOptionId', 'getSelectionId', 'getProductId', '__wakeup'])->disableOriginalConstructor()->getMock(); $selection->expects($this->any())->method('getSku')->will($this->returnValue($childSku . '_invalid')); $selection->expects($this->any())->method('getOptionId')->will($this->returnValue($optionId)); $selection->expects($this->any())->method('getSelectionId')->will($this->returnValue(55)); $selection->expects($this->any())->method('getProductId')->will($this->returnValue(1)); $this->option->expects($this->any())->method('getSelections')->will($this->returnValue([$selection])); $this->service->removeChild($productSku, $optionId, $childSku); }