public function testLoadBundleProduct() { $productId = 'test_id'; $productSku = 'test_sku'; $this->productRepository->expects($this->once())->method('get')->with($productId)->will($this->returnValue($this->product)); $this->product->expects($this->once())->method('getTypeId')->will($this->returnValue(\Magento\Catalog\Model\Product\Type::TYPE_BUNDLE)); $this->product->expects($this->once())->method('getSku')->will($this->returnValue($productSku)); $optionCustomAttributeValue = ['a', 'b']; $this->optionReadService->expects($this->once())->method('getList')->with($productSku)->will($this->returnValue($optionCustomAttributeValue)); $this->productBuilder->expects($this->at(0))->method('setCustomAttribute')->with('bundle_product_options', $optionCustomAttributeValue); $this->model->load($productId, $this->productBuilder); }
public function testUpdate() { $product1Sku = 'sku1'; $productOption1Sku = 'productOption1Sku'; $productOption2Sku = 'productOption2Sku'; $product1Options = [$this->productOption1, $this->productOption2]; $product2Options = [$this->productOption1]; $this->productRepository->expects($this->once())->method('get')->with($product1Sku, true)->will($this->returnValue($this->product)); $this->product->expects($this->once())->method('getTypeId')->will($this->returnValue(ProductType::TYPE_BUNDLE)); $this->optionReadService->expects($this->once())->method('getList')->with($product1Sku)->will($this->returnValue($product1Options)); $this->productData->expects($this->once())->method('getCustomAttribute')->with('bundle_product_options')->will($this->returnValue($this->attributeValue)); $this->attributeValue->expects($this->any())->method('getValue')->will($this->returnValue($product2Options)); $this->productOption1->expects($this->any())->method('getId')->will($this->returnValue($productOption1Sku)); $this->productOption2->expects($this->any())->method('getId')->will($this->returnValue($productOption2Sku)); $this->optionWriteService->expects($this->once())->method('remove')->with($product1Sku, $productOption2Sku)->will($this->returnValue(1)); $this->assertEquals($product1Sku, $this->saveProcessor->update($product1Sku, $this->productData)); }