public function testValidateMiniumumAmountNegative() { $storeId = 1; $this->quote->setStoreId($storeId); $valueMap = [['sales/minimum_order/active', ScopeInterface::SCOPE_STORE, $storeId, true], ['sales/minimum_order/multi_address', ScopeInterface::SCOPE_STORE, $storeId, true], ['sales/minimum_order/amount', ScopeInterface::SCOPE_STORE, $storeId, 20], ['sales/minimum_order/tax_including', ScopeInterface::SCOPE_STORE, $storeId, true]]; $this->scopeConfig->expects($this->any())->method('isSetFlag')->will($this->returnValueMap($valueMap)); $this->quoteAddressMock->expects($this->once())->method('validateMinimumAmount')->willReturn(false); $this->quoteAddressCollectionMock->expects($this->once())->method('setQuoteFilter')->willReturn([$this->quoteAddressMock]); $this->assertFalse($this->quote->validateMinimumAmount()); }
public function testGetSharedStoreIds() { $sharedIds = null; $storeIds = [1, 2, 3]; $storeId = 1; $websiteMock = $this->getMockBuilder('Magento\\Store\\Model\\Website')->disableOriginalConstructor()->getMock(); $websiteMock->expects($this->once())->method('getStoreIds')->will($this->returnValue($storeIds)); $storeMock = $this->getMockBuilder('Magento\\Store\\Model\\Store')->disableOriginalConstructor()->getMock(); $storeMock->expects($this->once())->method('getWebsite')->will($this->returnValue($websiteMock)); $this->storeManagerMock->expects($this->once())->method('getStore')->with($storeId)->will($this->returnValue($storeMock)); $this->quote->setData('shared_store_ids', $sharedIds); $this->quote->setStoreId($storeId); $result = $this->quote->getSharedStoreIds(); $this->assertEquals($storeIds, $result); }
/** * Retrieve quote model object * * @return \Magento\Sales\Model\Quote */ public function getQuote() { if (is_null($this->_quote)) { $this->_quote = $this->_quoteFactory->create(); if ($this->getStoreId() && $this->getQuoteId()) { $this->_quote->setStoreId($this->getStoreId())->load($this->getQuoteId()); } elseif ($this->getStoreId() && $this->hasCustomerId()) { $customerGroupId = $this->_scopeConfig->getValue(self::XML_PATH_DEFAULT_CREATEACCOUNT_GROUP, \Magento\Store\Model\ScopeInterface::SCOPE_STORE); $this->_quote->setStoreId($this->getStoreId())->setCustomerGroupId($customerGroupId)->setIsActive(false)->save(); $this->setQuoteId($this->_quote->getId()); try { $customerData = $this->_customerService->getCustomer($this->getCustomerId()); $this->_quote->assignCustomer($customerData); } catch (\Magento\Framework\Exception\NoSuchEntityException $e) { /** Customer does not exist */ } } $this->_quote->setIgnoreOldQty(true); $this->_quote->setIsSuperMode(true); } return $this->_quote; }