10 use \Magento\Persistent\Observer\RemovePersistentCookieOnRegisterObserver;
51 $this->persistentSessionMock = $this->createMock(\
Magento\Persistent\Helper\Session::class);
52 $this->sessionModelMock = $this->createMock(\
Magento\Persistent\Model\Session::class);
53 $this->persistentDataMock = $this->createMock(\
Magento\Persistent\Helper\Data::class);
54 $this->customerSessionMock = $this->createMock(\
Magento\Customer\Model\Session::class);
55 $this->quoteManagerMock = $this->createMock(\
Magento\Persistent\Model\QuoteManager::class);
56 $this->observerMock = $this->createMock(\
Magento\Framework\Event\Observer::class);
59 $this->persistentSessionMock,
60 $this->persistentDataMock,
61 $this->customerSessionMock,
62 $this->quoteManagerMock
68 $this->persistentDataMock->expects($this->once())
69 ->method(
'canProcess')->with($this->observerMock)->will($this->returnValue(
false));
70 $this->persistentSessionMock->expects($this->never())->method(
'getSession');
72 $this->model->execute($this->observerMock);
77 $this->persistentDataMock->expects($this->once())
78 ->method(
'canProcess')->with($this->observerMock)->will($this->returnValue(
true));
79 $this->persistentSessionMock->expects($this->once())->method(
'isPersistent')->will($this->returnValue(
false));
81 $this->persistentSessionMock->expects($this->never())->method(
'getSession');
83 $this->model->execute($this->observerMock);
88 $this->persistentDataMock->expects($this->once())
89 ->method(
'canProcess')->with($this->observerMock)->will($this->returnValue(
true));
90 $this->persistentSessionMock->expects($this->once())->method(
'isPersistent')->will($this->returnValue(
true));
91 $this->persistentSessionMock->expects($this->once())
92 ->method(
'getSession')->will($this->returnValue($this->sessionModelMock));
93 $this->sessionModelMock->expects($this->once())->method(
'removePersistentCookie')->will($this->returnSelf());
94 $this->customerSessionMock->expects($this->once())->method(
'isLoggedIn')->will($this->returnValue(
false));
95 $this->customerSessionMock->expects($this->once())
96 ->method(
'setCustomerId')->with(
null)->will($this->returnSelf());
97 $this->customerSessionMock->expects($this->once())
98 ->method(
'setCustomerGroupId')->with(
null)->will($this->returnSelf());
99 $this->quoteManagerMock->expects($this->once())->method(
'setGuest');
101 $this->model->execute($this->observerMock);
106 $this->persistentDataMock->expects($this->once())
107 ->method(
'canProcess')->with($this->observerMock)->will($this->returnValue(
true));
108 $this->persistentSessionMock->expects($this->once())->method(
'isPersistent')->will($this->returnValue(
true));
109 $this->persistentSessionMock->expects($this->once())
110 ->method(
'getSession')->will($this->returnValue($this->sessionModelMock));
111 $this->sessionModelMock->expects($this->once())->method(
'removePersistentCookie')->will($this->returnSelf());
112 $this->customerSessionMock->expects($this->once())->method(
'isLoggedIn')->will($this->returnValue(
true));
113 $this->customerSessionMock->expects($this->never())->method(
'setCustomerId');
114 $this->customerSessionMock->expects($this->never())->method(
'setCustomerGroupId');
115 $this->quoteManagerMock->expects($this->once())->method(
'setGuest');
117 $this->model->execute($this->observerMock);
testExecuteWithNotLoggedInCustomer()
testExecuteWithPersistentDataThatCanNotBeProcess()
testExecuteWhenSessionIsNotPersistent()