public function testAroundLoad()
 {
     $productMock = $this->getMock('\\Magento\\Catalog\\Model\\Product', ['getTypeId', 'setExtensionAttributes'], [], '', false);
     $closure = function () use($productMock) {
         return $productMock;
     };
     $productMock->expects($this->once())->method('getTypeId')->willReturn(\Magento\Catalog\Model\Product\Type::TYPE_BUNDLE);
     $optionMock = $this->getMock('\\Magento\\Bundle\\Api\\Data\\OptionInterface');
     $this->optionListMock->expects($this->once())->method('getItems')->with($productMock)->willReturn([$optionMock]);
     $productExtensionMock = $this->getMockBuilder('\\Magento\\Catalog\\Api\\Data\\ProductExtension')->disableOriginalConstructor()->setMethods(['setBundleProductOptions', 'getBundleProductOptions'])->getMock();
     $this->productExtensionFactory->expects($this->once())->method('create')->willReturn($productExtensionMock);
     $productExtensionMock->expects($this->once())->method('setBundleProductOptions')->with([$optionMock])->willReturnSelf();
     $productMock->expects($this->once())->method('setExtensionAttributes')->with($productExtensionMock)->willReturnSelf();
     $this->assertEquals($productMock, $this->model->aroundLoad($productMock, $closure, 100, null));
 }
Beispiel #2
0
 public function testAroundLoad()
 {
     $productMock = $this->getMock('\\Magento\\Catalog\\Model\\Product', ['getTypeId', 'getCustomAttributes', 'setData'], [], '', false);
     $closure = function () use($productMock) {
         return $productMock;
     };
     $productMock->expects($this->once())->method('getTypeId')->willReturn(\Magento\Catalog\Model\Product\Type::TYPE_BUNDLE);
     $optionMock = $this->getMock('\\Magento\\Bundle\\Api\\Data\\OptionInterface');
     $this->optionListMock->expects($this->once())->method('getItems')->with($productMock)->willReturn([$optionMock]);
     $this->attributeBuilderMock->expects($this->once())->method('setAttributeCode')->with('bundle_product_options')->willReturnSelf();
     $this->attributeBuilderMock->expects($this->once())->method('setValue')->with([$optionMock])->willReturnSelf();
     $customAttributeMock = $this->getMock('\\Magento\\Framework\\Api\\AttributeValue', [], [], '', false);
     $this->attributeBuilderMock->expects($this->once())->method('create')->willReturn($customAttributeMock);
     $productAttributeMock = $this->getMock('\\Magento\\Framework\\Api\\AttributeValue', [], [], '', false);
     $productMock->expects($this->once())->method('getCustomAttributes')->willReturn([$productAttributeMock]);
     $productMock->expects($this->once())->method('setData')->with('custom_attributes', ['bundle_product_options' => $customAttributeMock, $productAttributeMock])->willReturnSelf();
     $this->assertEquals($productMock, $this->model->aroundLoad($productMock, $closure, 100, null));
 }