public function testSetStore() { $storeId = 1; $storeMock = $this->getMockBuilder('Magento\\Store\\Model\\Store')->disableOriginalConstructor()->getMock(); $storeMock->expects($this->once())->method('getId')->will($this->returnValue($storeId)); $result = $this->quote->setStore($storeMock); $this->assertInstanceOf('Magento\\Sales\\Model\\Quote', $result); }
/** * Retrieve customer cart quote object model * * @return \Magento\Sales\Model\Quote */ public function getCustomerCart() { if (!is_null($this->_cart)) { return $this->_cart; } $this->_cart = $this->_objectManager->create('Magento\\Sales\\Model\\Quote'); $customerId = (int) $this->getSession()->getCustomerId(); if ($customerId) { $this->_cart->setStore($this->getSession()->getStore())->loadByCustomer($customerId); if (!$this->_cart->getId()) { $customerData = $this->_customerAccountService->getCustomer($customerId); $this->_cart->assignCustomer($customerData); $this->_cart->save(); } } return $this->_cart; }