/** * Loads customer, quote and quote item by request params * * @return $this * @throws \Magento\Framework\Exception\LocalizedException */ protected function _initData() { $this->_customerId = (int) $this->getRequest()->getParam('customer_id'); if (!$this->_customerId) { throw new \Magento\Framework\Exception\LocalizedException(__('No customer ID defined.')); } $quoteItemId = (int) $this->getRequest()->getParam('id'); $websiteId = (int) $this->getRequest()->getParam('website_id'); try { $this->_quote = $this->quoteRepository->getForCustomer($this->_customerId); } catch (\Magento\Framework\Exception\NoSuchEntityException $e) { $this->_quote = $this->quoteRepository->create(); } $this->_quote->setWebsite($this->_objectManager->get('Magento\\Store\\Model\\StoreManagerInterface')->getWebsite($websiteId)); $this->_quoteItem = $this->_quote->getItemById($quoteItemId); if (!$this->_quoteItem) { throw new LocalizedException(__('Please correct the quote items and try again.')); } return $this; }
public function testGetSharedWebsiteStoreIds() { $sharedIds = null; $storeIds = [1, 2, 3]; $websiteMock = $this->getMockBuilder('Magento\\Store\\Model\\Website')->disableOriginalConstructor()->getMock(); $websiteMock->expects($this->once())->method('getStoreIds')->will($this->returnValue($storeIds)); $this->quote->setData('shared_store_ids', $sharedIds); $this->quote->setWebsite($websiteMock); $result = $this->quote->getSharedStoreIds(); $this->assertEquals($storeIds, $result); }