42 $this->productMock = $this->createPartialMock(\
Magento\Catalog\Model\Product::class, [
'__wakeup',
'getStore']);
43 $store = $this->createPartialMock(\
Magento\Store\Model\Store::class, [
'getWebsiteId',
'__wakeup']);
44 $store->expects($this->any())->method(
'getWebsiteId')->willReturn(0);
45 $this->productMock->expects($this->any())->method(
'getStore')->willReturn(
$store);
47 $this->duplicateMock = $this->createPartialMock(
48 \
Magento\Catalog\Model\Product::class,
49 [
'setStockData',
'__wakeup']
52 $this->stockItemDoMock = $this->getMockForAbstractClass(
53 \
Magento\CatalogInventory\Api\Data\StockItemInterface::class,
56 'getUseConfigEnableQtyInc',
57 'getEnableQtyIncrements',
58 'gerUseConfigQtyIncrements',
63 $this->stockRegistry = $this->getMockForAbstractClass(
64 \
Magento\CatalogInventory\Api\StockRegistryInterface::class,
68 $this->objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this);
69 $this->model = $this->objectManager->getObject(
70 \
Magento\CatalogInventory\Model\Product\CopyConstructor\CatalogInventory::class,
71 [
'stockRegistry' => $this->stockRegistry]
78 'use_config_min_qty' => 1,
79 'use_config_min_sale_qty' => 1,
80 'use_config_max_sale_qty' => 1,
81 'use_config_backorders' => 1,
82 'use_config_notify_stock_qty' => 1,
84 $this->stockItemDoMock->expects($this->any())->method(
'getStockId')->will($this->returnValue(
false));
86 $this->stockRegistry->expects($this->once())
87 ->method(
'getStockItem')
88 ->will($this->returnValue($this->stockItemDoMock));
90 $this->duplicateMock->expects($this->once())->method(
'setStockData')->with($expectedData);
91 $this->model->build($this->productMock, $this->duplicateMock);
97 'use_config_min_qty' => 1,
98 'use_config_min_sale_qty' => 1,
99 'use_config_max_sale_qty' => 1,
100 'use_config_backorders' => 1,
101 'use_config_notify_stock_qty' => 1,
102 'use_config_enable_qty_inc' =>
'use_config_enable_qty_inc',
103 'enable_qty_increments' =>
'enable_qty_increments',
104 'use_config_qty_increments' =>
'use_config_qty_increments',
105 'qty_increments' =>
'qty_increments',
107 $this->stockRegistry->expects($this->once())
108 ->method(
'getStockItem')
109 ->will($this->returnValue($this->stockItemDoMock));
111 $this->stockItemDoMock->expects($this->any())->method(
'getItemId')->will($this->returnValue(50));
112 $this->stockItemDoMock->expects($this->any())
113 ->method(
'getUseConfigEnableQtyInc')
114 ->will($this->returnValue(
'use_config_enable_qty_inc'));
115 $this->stockItemDoMock->expects($this->any())
116 ->method(
'getEnableQtyIncrements')
117 ->will($this->returnValue(
'enable_qty_increments'));
118 $this->stockItemDoMock->expects($this->any())
119 ->method(
'getUseConfigQtyIncrements')
120 ->will($this->returnValue(
'use_config_qty_increments'));
121 $this->stockItemDoMock->expects($this->any())
122 ->method(
'getQtyIncrements')
123 ->will($this->returnValue(
'qty_increments'));
125 $this->duplicateMock->expects($this->once())->method(
'setStockData')->with($expectedData);
126 $this->model->build($this->productMock, $this->duplicateMock);
testBuildWithCurrentProductStockItem()
testBuildWithoutCurrentProductStockItem()