Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
SetLoadPersistentQuoteObserverTest.php
Go to the documentation of this file.
1 <?php
9 
10 class SetLoadPersistentQuoteObserverTest extends \PHPUnit\Framework\TestCase
11 {
15  protected $model;
16 
20  protected $helperMock;
21 
25  protected $sessionHelperMock;
26 
31 
36 
40  protected $observerMock;
41 
42  protected function setUp()
43  {
44  $this->helperMock = $this->createMock(\Magento\Persistent\Helper\Data::class);
45  $this->sessionHelperMock = $this->createMock(\Magento\Persistent\Helper\Session::class);
46  $this->checkoutSessionMock = $this->createMock(\Magento\Checkout\Model\Session::class);
47  $this->customerSessionMock = $this->createMock(\Magento\Customer\Model\Session::class);
48  $this->observerMock = $this->createMock(\Magento\Framework\Event\Observer::class);
49 
50  $this->model = new \Magento\Persistent\Observer\SetLoadPersistentQuoteObserver(
51  $this->sessionHelperMock,
52  $this->helperMock,
53  $this->customerSessionMock,
54  $this->checkoutSessionMock
55  );
56  }
57 
59  {
60  $this->sessionHelperMock->expects($this->once())->method('isPersistent')->will($this->returnValue(false));
61  $this->checkoutSessionMock->expects($this->never())->method('setLoadInactive');
62  $this->model->execute($this->observerMock);
63  }
64 
65  public function testExecute()
66  {
67  $this->sessionHelperMock->expects($this->once())->method('isPersistent')->will($this->returnValue(true));
68  $this->customerSessionMock->expects($this->once())->method('isLoggedIn')->will($this->returnValue(false));
69  $this->helperMock->expects($this->once())->method('isShoppingCartPersist')->will($this->returnValue(true));
70  $this->checkoutSessionMock->expects($this->never())->method('setLoadInactive');
71  $this->model->execute($this->observerMock);
72  }
73 }