Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
SalesQuoteSaveAfterObserverTest.php
Go to the documentation of this file.
1 <?php
7 
9 
10 class SalesQuoteSaveAfterObserverTest extends \PHPUnit\Framework\TestCase
11 {
13  protected $object;
14 
16  protected $objectManager;
17 
19  protected $checkoutSession;
20 
21  protected function setUp()
22  {
23  $this->objectManager = new ObjectManager($this);
24  $this->checkoutSession = $this->createMock(\Magento\Checkout\Model\Session::class);
25  $this->object = $this->objectManager->getObject(
26  \Magento\Checkout\Observer\SalesQuoteSaveAfterObserver::class,
27  ['checkoutSession' => $this->checkoutSession]
28  );
29  }
30 
31  public function testSalesQuoteSaveAfter()
32  {
33  $observer = $this->createMock(\Magento\Framework\Event\Observer::class);
34  $observer->expects($this->once())->method('getEvent')->will(
35  $this->returnValue(new \Magento\Framework\DataObject(
36  ['quote' => new \Magento\Framework\DataObject(['is_checkout_cart' => 1, 'id' => 7])]
37  ))
38  );
39  $this->checkoutSession->expects($this->once())->method('getQuoteId')->with(7);
40 
41  $this->object->execute($observer);
42  }
43 }