8 use \Magento\Shipping\Model\Shipping;
44 $this->carrier = $this->createMock(\
Magento\
Shipping\Model\Carrier\AbstractCarrier::class);
45 $this->carrier->expects($this->any())->method(
'getConfigData')->will($this->returnCallback(
function ($key) {
47 'max_package_weight' => 10,
51 $this->stockRegistry = $this->createMock(\
Magento\CatalogInventory\Model\StockRegistry::class);
52 $this->stockItemData = $this->createMock(\
Magento\CatalogInventory\Model\Stock\Item::class);
54 $objectManagerHelper =
new ObjectManagerHelper($this);
55 $this->shipping = $objectManagerHelper->getObject(
57 [
'stockRegistry' => $this->stockRegistry]
69 ->disableOriginalConstructor()
71 'getQty',
'getIsQtyDecimal',
'getProductType',
'getProduct',
'getWeight',
'__wakeup',
'getStore',
76 $item->expects($this->any())->method(
'getQty')->will($this->returnValue(1));
77 $item->expects($this->any())->method(
'getWeight')->will($this->returnValue(10));
78 $item->expects($this->any())->method(
'getIsQtyDecimal')->will($this->returnValue(
true));
79 $item->expects($this->any())->method(
'getProductType')
80 ->will($this->returnValue(\
Magento\Catalog\Model\Product\Type::TYPE_SIMPLE));
81 $item->expects($this->any())->method(
'getProduct')->will($this->returnValue(
$product));
83 $store = $this->createPartialMock(\
Magento\
Store\Model\Store::class, [
'getWebsiteId']);
84 $store->expects($this->any())
85 ->method(
'getWebsiteId')
86 ->will($this->returnValue(10));
87 $item->expects($this->any())->method(
'getStore')->will($this->returnValue(
$store));
89 $product->expects($this->any())->method(
'getId')->will($this->returnValue($this->productId));
92 $this->stockItemData->expects($this->any())->method(
'getIsDecimalDivided')->will($this->returnValue(
true));
95 $this->stockRegistry->expects($this->atLeastOnce())->method(
'getStockItem')
96 ->with($this->productId, 10)
97 ->will($this->returnValue($this->stockItemData));
99 $this->stockItemData->expects($this->atLeastOnce())
100 ->method(
'getEnableQtyIncrements')
101 ->will($this->returnValue(
true));
102 $this->stockItemData->expects($this->atLeastOnce())->method(
'getQtyIncrements')
103 ->will($this->returnValue(0.5));
105 $this->shipping->composePackagesForCarrier($this->carrier,
$request);