54 $eventMethods = [
'getControllerAction',
'dispatch',
'__wakeUp'];
55 $this->customerSessionMock = $this->createMock(\
Magento\Customer\Model\Session::class);
56 $this->sessionHelperMock = $this->createMock(\
Magento\Persistent\Helper\Session::class);
57 $this->helperMock = $this->createMock(\
Magento\Persistent\Helper\Data::class);
58 $this->observerMock = $this->createMock(\
Magento\Framework\Event\Observer::class);
59 $this->eventMock = $this->createPartialMock(\
Magento\Framework\Event::class, $eventMethods);
60 $this->actionMock = $this->createMock(\
Magento\Persistent\Controller\Index::class);
61 $this->observerMock->expects($this->once())->method(
'getEvent')->will($this->returnValue($this->eventMock));
62 $this->model = new \Magento\Persistent\Observer\PreventClearCheckoutSessionObserver(
63 $this->sessionHelperMock,
65 $this->customerSessionMock
72 ->expects($this->once())
73 ->method(
'getControllerAction')
74 ->will($this->returnValue($this->actionMock));
75 $this->sessionHelperMock->expects($this->once())->method(
'isPersistent')->will($this->returnValue(
true));
76 $this->customerSessionMock->expects($this->once())->method(
'isLoggedIn')->will($this->returnValue(
false));
77 $this->helperMock->expects($this->never())->method(
'isShoppingCartPersist');
78 $this->actionMock->expects($this->once())->method(
'setClearCheckoutSession')->with(
false);
79 $this->model->execute($this->observerMock);
85 ->expects($this->once())
86 ->method(
'getControllerAction')
87 ->will($this->returnValue($this->actionMock));
88 $this->sessionHelperMock->expects($this->once())->method(
'isPersistent')->will($this->returnValue(
true));
89 $this->customerSessionMock->expects($this->once())->method(
'isLoggedIn')->will($this->returnValue(
true));
90 $this->helperMock->expects($this->once())->method(
'isShoppingCartPersist')->will($this->returnValue(
false));
91 $this->actionMock->expects($this->once())->method(
'setClearCheckoutSession')->with(
false);
92 $this->model->execute($this->observerMock);
98 ->expects($this->once())
99 ->method(
'getControllerAction');
100 $this->sessionHelperMock->expects($this->never())->method(
'isPersistent');
101 $this->actionMock->expects($this->never())->method(
'setClearCheckoutSession');
102 $this->model->execute($this->observerMock);
testExecuteWhenSessionIsPersist()
testExecuteWhenActionIsNotPersistent()
testExecuteWhenShoppingCartIsPersist()