Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@

use Magento\Framework\Event\ObserverInterface;

/**
* Class SalesQuoteSaveAfterObserver
*/
class SalesQuoteSaveAfterObserver implements ObserverInterface
{
/**
Expand All @@ -24,15 +27,18 @@ public function __construct(\Magento\Checkout\Model\Session $checkoutSession)
}

/**
* Assign quote to session
*
* @param \Magento\Framework\Event\Observer $observer
* @return void
*/
public function execute(\Magento\Framework\Event\Observer $observer)
{
/* @var \Magento\Quote\Model\Quote $quote */
$quote = $observer->getEvent()->getQuote();
/* @var $quote \Magento\Quote\Model\Quote */

if ($quote->getIsCheckoutCart()) {
$this->checkoutSession->getQuoteId($quote->getId());
$this->checkoutSession->setQuoteId($quote->getId());
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,14 @@ protected function setUp()

public function testSalesQuoteSaveAfter()
{
$quoteId = 7;
$observer = $this->createMock(\Magento\Framework\Event\Observer::class);
$observer->expects($this->once())->method('getEvent')->will(
$this->returnValue(new \Magento\Framework\DataObject(
['quote' => new \Magento\Framework\DataObject(['is_checkout_cart' => 1, 'id' => 7])]
['quote' => new \Magento\Framework\DataObject(['is_checkout_cart' => 1, 'id' => $quoteId])]
))
);
$this->checkoutSession->expects($this->once())->method('getQuoteId')->with(7);
$this->checkoutSession->expects($this->once())->method('setQuoteId')->with($quoteId);

$this->object->execute($observer);
}
Expand Down