Skip to content

Commit

Permalink
ENGCOM-3578: Fix: SalesQuoteSaveAfterObserver fails to update the che…
Browse files Browse the repository at this point in the history
…ckout session quote id when applicable #19425
  • Loading branch information
sidolov authored Dec 6, 2018
2 parents 8c13cb0 + ca75474 commit 0c90778
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
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

0 comments on commit 0c90778

Please sign in to comment.