コード例 #1
0
 /**
  * @covers \Magento\Shipping\Model\Shipping::composePackagesForCarrier
  */
 public function testComposePackages()
 {
     $request = new RateRequest();
     /** \Magento\Catalog\Model\Product\Configuration\Item\ItemInterface */
     $item = $this->getMockBuilder('\\Magento\\Quote\\Model\\Quote\\Item')->disableOriginalConstructor()->setMethods(['getQty', 'getIsQtyDecimal', 'getProductType', 'getProduct', 'getWeight', '__wakeup', 'getStore'])->getMock();
     $product = $this->getMock('Magento\\Catalog\\Model\\Product', [], [], '', false);
     $item->expects($this->any())->method('getQty')->will($this->returnValue(1));
     $item->expects($this->any())->method('getWeight')->will($this->returnValue(10));
     $item->expects($this->any())->method('getIsQtyDecimal')->will($this->returnValue(true));
     $item->expects($this->any())->method('getProductType')->will($this->returnValue(\Magento\Catalog\Model\Product\Type::TYPE_SIMPLE));
     $item->expects($this->any())->method('getProduct')->will($this->returnValue($product));
     $store = $this->getMock('Magento\\Store\\Model\\Store', ['getWebsiteId'], [], '', false);
     $store->expects($this->any())->method('getWebsiteId')->will($this->returnValue(10));
     $item->expects($this->any())->method('getStore')->will($this->returnValue($store));
     $product->expects($this->any())->method('getId')->will($this->returnValue($this->productId));
     $request->setData('all_items', [$item]);
     $this->stockItemData->expects($this->any())->method('getIsDecimalDivided')->will($this->returnValue(true));
     /** Testable service calls to CatalogInventory module */
     $this->stockRegistry->expects($this->atLeastOnce())->method('getStockItem')->with($this->productId, 10)->will($this->returnValue($this->stockItemData));
     $this->stockItemData->expects($this->atLeastOnce())->method('getEnableQtyIncrements')->will($this->returnValue(true));
     $this->stockItemData->expects($this->atLeastOnce())->method('getQtyIncrements')->will($this->returnValue(0.5));
     $this->shipping->composePackagesForCarrier($this->carrier, $request);
 }
コード例 #2
0
ファイル: Labels.php プロジェクト: Doability/magento2dev
 /**
  * @param \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig
  * @param \Magento\Shipping\Model\Config $shippingConfig
  * @param \Magento\Store\Model\StoreManagerInterface $storeManager
  * @param \Magento\Shipping\Model\CarrierFactory $carrierFactory
  * @param \Magento\Shipping\Model\Rate\ResultFactory $rateResultFactory
  * @param \Magento\Shipping\Model\Shipment\RequestFactory $shipmentRequestFactory
  * @param \Magento\Directory\Model\RegionFactory $regionFactory
  * @param \Magento\Framework\Math\Division $mathDivision
  * @param \Magento\CatalogInventory\Api\StockRegistryInterface $stockRegistry
  * @param \Magento\Backend\Model\Auth\Session $authSession
  * @param \Magento\Shipping\Model\Shipment\Request $request
  * @SuppressWarnings(PHPMD.ExcessiveParameterList)
  */
 public function __construct(\Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig, \Magento\Shipping\Model\Config $shippingConfig, \Magento\Store\Model\StoreManagerInterface $storeManager, \Magento\Shipping\Model\CarrierFactory $carrierFactory, \Magento\Shipping\Model\Rate\ResultFactory $rateResultFactory, \Magento\Shipping\Model\Shipment\RequestFactory $shipmentRequestFactory, \Magento\Directory\Model\RegionFactory $regionFactory, \Magento\Framework\Math\Division $mathDivision, \Magento\CatalogInventory\Api\StockRegistryInterface $stockRegistry, \Magento\Backend\Model\Auth\Session $authSession, Request $request)
 {
     $this->_authSession = $authSession;
     $this->_request = $request;
     parent::__construct($scopeConfig, $shippingConfig, $storeManager, $carrierFactory, $rateResultFactory, $shipmentRequestFactory, $regionFactory, $mathDivision, $stockRegistry);
 }