Skip to content

Commit 1867abc

Browse files
Raj MohanRaj Mohan
authored andcommitted
AC-12092_PHPUnit10: Failure Fix for CatalogInventory Module
1 parent 6673030 commit 1867abc

File tree

1 file changed

+14
-5
lines changed

1 file changed

+14
-5
lines changed

app/code/Magento/CatalogInventory/Test/Unit/Block/Stockqty/DefaultStockqtyTest.php

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -133,20 +133,29 @@ public function testGetStockQtyLeft()
133133
$storeMock = $this->getMockBuilder(Store::class)
134134
->disableOriginalConstructor()
135135
->getMock();
136+
$product = $this->createMock(Product::class);
137+
$product->expects($this->once())
138+
->method('getStore')
139+
->willReturn($storeMock);
136140
$storeMock->expects($this->once())
137141
->method('getWebsiteId')
138142
->willReturn($websiteId);
139-
$product = $this->createMock(Product::class);
140143
$product->expects($this->any())
141144
->method('getId')
142145
->willReturn($productId);
143-
$product->expects($this->once())
144-
->method('getStore')
145-
->willReturn($storeMock);
146-
$this->registryMock->expects($this->once())
146+
$this->registryMock->expects($this->any())
147147
->method('registry')
148148
->with('current_product')
149149
->willReturn($product);
150+
if ($productId) {
151+
$stockStatus = $this->getMockBuilder(StockStatusInterface::class)
152+
->getMockForAbstractClass();
153+
$stockStatus->expects($this->any())->method('getQty')->willReturn($stockQty);
154+
$this->stockRegistryMock->expects($this->once())
155+
->method('getStockStatus')
156+
->with($productId, $websiteId)
157+
->willReturn($stockStatus);
158+
}
150159

151160
$stockItemMock = $this->getMockBuilder(StockItemInterface::class)
152161
->disableOriginalConstructor()

0 commit comments

Comments
 (0)