35 $objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this);
36 $this->registryMock = $this->createMock(\
Magento\Framework\Registry::class);
37 $this->stockItem = $this->getMockBuilder(\
Magento\CatalogInventory\Api\Data\StockItemInterface::class)
38 ->setMethods([
'getQtyIncrements',
'getStockItem'])
39 ->getMockForAbstractClass();
40 $this->stockItem->expects($this->any())->method(
'getStockItem')->willReturn(1);
41 $this->stockRegistry = $this->getMockForAbstractClass(
42 \
Magento\CatalogInventory\Api\StockRegistryInterface::class,
47 $this->stockRegistry->expects($this->any())->method(
'getStockItem')->willReturn($this->stockItem);
50 \
Magento\CatalogInventory\Block\Qtyincrements::class,
52 'registry' => $this->registryMock,
53 'stockRegistry' => $this->stockRegistry
65 $productTags = [
'catalog_product_1'];
67 $product->expects($this->once())->method(
'getIdentities')->will($this->returnValue($productTags));
68 $store = $this->createPartialMock(\
Magento\Store\Model\Store::class, [
'getWebsiteId',
'__wakeup']);
69 $store->expects($this->any())->method(
'getWebsiteId')->willReturn(0);
70 $product->expects($this->any())->method(
'getStore')->will($this->returnValue(
$store));
71 $this->registryMock->expects($this->once())
73 ->with(
'current_product')
74 ->will($this->returnValue(
$product));
75 $this->assertEquals($productTags, $this->block->getIdentities());
87 $this->stockItem->expects($this->once())
88 ->method(
'getQtyIncrements')
89 ->will($this->returnValue($qtyInc));
92 $product->expects($this->once())->method(
'getId')->will($this->returnValue(
$productId));
93 $product->expects($this->once())->method(
'isSaleable')->will($this->returnValue(
$isSaleable));
94 $store = $this->createPartialMock(\
Magento\Store\Model\Store::class, [
'getWebsiteId',
'__wakeup']);
95 $store->expects($this->any())->method(
'getWebsiteId')->willReturn(0);
96 $product->expects($this->any())->method(
'getStore')->will($this->returnValue(
$store));
98 $this->registryMock->expects($this->any())
100 ->with(
'current_product')
101 ->will($this->returnValue(
$product));
103 $this->assertSame(
$result, $this->block->getProductQtyIncrements());
105 $this->assertSame(
$result, $this->block->getProductQtyIncrements());
115 [1, 100,
false,
false],
testGetProductQtyIncrements($productId, $qtyInc, $isSaleable, $result)
getProductQtyIncrementsDataProvider()