File tree Expand file tree Collapse file tree 2 files changed +11
-4
lines changed
app/code/Magento/Checkout Expand file tree Collapse file tree 2 files changed +11
-4
lines changed Original file line number Diff line number Diff line change 7
7
8
8
use Magento \Framework \Event \ObserverInterface ;
9
9
10
+ /**
11
+ * Class SalesQuoteSaveAfterObserver
12
+ */
10
13
class SalesQuoteSaveAfterObserver implements ObserverInterface
11
14
{
12
15
/**
@@ -24,15 +27,18 @@ public function __construct(\Magento\Checkout\Model\Session $checkoutSession)
24
27
}
25
28
26
29
/**
30
+ * Assign quote to session
31
+ *
27
32
* @param \Magento\Framework\Event\Observer $observer
28
33
* @return void
29
34
*/
30
35
public function execute (\Magento \Framework \Event \Observer $ observer )
31
36
{
37
+ /* @var \Magento\Quote\Model\Quote $quote */
32
38
$ quote = $ observer ->getEvent ()->getQuote ();
33
- /* @var $quote \Magento\Quote\Model\Quote */
39
+
34
40
if ($ quote ->getIsCheckoutCart ()) {
35
- $ this ->checkoutSession ->getQuoteId ($ quote ->getId ());
41
+ $ this ->checkoutSession ->setQuoteId ($ quote ->getId ());
36
42
}
37
43
}
38
44
}
Original file line number Diff line number Diff line change @@ -30,13 +30,14 @@ protected function setUp()
30
30
31
31
public function testSalesQuoteSaveAfter ()
32
32
{
33
+ $ quoteId = 7 ;
33
34
$ observer = $ this ->createMock (\Magento \Framework \Event \Observer::class);
34
35
$ observer ->expects ($ this ->once ())->method ('getEvent ' )->will (
35
36
$ this ->returnValue (new \Magento \Framework \DataObject (
36
- ['quote ' => new \Magento \Framework \DataObject (['is_checkout_cart ' => 1 , 'id ' => 7 ])]
37
+ ['quote ' => new \Magento \Framework \DataObject (['is_checkout_cart ' => 1 , 'id ' => $ quoteId ])]
37
38
))
38
39
);
39
- $ this ->checkoutSession ->expects ($ this ->once ())->method ('getQuoteId ' )->with (7 );
40
+ $ this ->checkoutSession ->expects ($ this ->once ())->method ('setQuoteId ' )->with ($ quoteId );
40
41
41
42
$ this ->object ->execute ($ observer );
42
43
}
You can’t perform that action at this time.
0 commit comments