34 $stockRegistryMock = $this->createMock(\
Magento\CatalogInventory\Api\StockRegistryInterface::class);
35 $this->productExtensionFactoryMock = $this->getMockBuilder(
36 \
Magento\Catalog\Api\Data\ProductExtensionFactory::class
38 ->setMethods([
'create'])
39 ->disableOriginalConstructor()
42 $this->plugin = new \Magento\CatalogInventory\Model\Plugin\AfterProductLoad(
44 $this->productExtensionFactoryMock
48 $stockItemMock = $this->createMock(\
Magento\CatalogInventory\Api\Data\StockItemInterface::class);
50 $stockRegistryMock->expects($this->once())
51 ->method(
'getStockItem')
53 ->willReturn($stockItemMock);
55 $this->productExtensionMock = $this->getMockBuilder(\
Magento\Catalog\Api\Data\ProductExtensionInterface::class)
56 ->setMethods([
'setStockItem'])
57 ->getMockForAbstractClass();
58 $this->productExtensionMock->expects($this->once())
59 ->method(
'setStockItem')
60 ->with($stockItemMock)
63 $this->productMock = $this->getMockBuilder(\
Magento\Catalog\Model\Product::class)
64 ->disableOriginalConstructor()
66 $this->productMock->expects($this->once())
67 ->method(
'setExtensionAttributes')
68 ->with($this->productExtensionMock)
70 $this->productMock->expects(($this->once()))
77 $this->productMock->expects($this->once())
78 ->method(
'getExtensionAttributes')
79 ->willReturn($this->productExtensionMock);
80 $this->productExtensionFactoryMock->expects($this->never())
85 $this->plugin->afterLoad($this->productMock)
$productExtensionFactoryMock