Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
UnsetAllObserverTest.php
Go to the documentation of this file.
1 <?php
7 
9 
10 class UnsetAllObserverTest 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\UnsetAllObserver::class,
27  ['checkoutSession' => $this->checkoutSession]
28  );
29  }
30 
31  public function testUnsetAll()
32  {
33  $this->checkoutSession->expects($this->once())->method('clearQuote')->will($this->returnSelf());
34  $this->checkoutSession->expects($this->once())->method('clearStorage')->will($this->returnSelf());
35 
36  $observerMock = $this->getMockBuilder(\Magento\Framework\Event\Observer::class)
37  ->disableOriginalConstructor()
38  ->getMock();
39 
40  $this->object->execute($observerMock);
41  }
42 }