59 $this->requestMock = $this->createMock(\
Magento\Framework\
App\Request\Http::class);
60 $this->helperMock = $this->createMock(\
Magento\Persistent\Helper\Data::class);
61 $this->sessionHelperMock = $this->createMock(\
Magento\Persistent\Helper\Session::class);
62 $this->customerSessionMock = $this->createMock(\
Magento\Customer\Model\Session::class);
63 $this->sessionFactoryMock =
64 $this->createPartialMock(\
Magento\Persistent\Model\SessionFactory::class, [
'create']);
65 $this->observerMock = $this->createMock(\
Magento\Framework\Event\Observer::class);
66 $eventMethods = [
'getRequest',
'__wakeUp'];
67 $this->eventManagerMock = $this->createPartialMock(\
Magento\Framework\Event::class, $eventMethods);
68 $this->sessionMock = $this->createMock(\
Magento\Persistent\Model\Session::class);
69 $this->model = new \Magento\Persistent\Observer\RenewCookieObserver(
71 $this->sessionHelperMock,
72 $this->customerSessionMock,
73 $this->sessionFactoryMock
80 ->expects($this->once())
81 ->method(
'canProcess')
82 ->with($this->observerMock)
83 ->will($this->returnValue(
true));
84 $this->helperMock->expects($this->once())->method(
'isEnabled')->will($this->returnValue(
true));
85 $this->sessionHelperMock->expects($this->once())->method(
'isPersistent')->will($this->returnValue(
true));
88 ->expects($this->once())
90 ->will($this->returnValue($this->eventManagerMock));
91 $this->eventManagerMock
92 ->expects($this->once())
93 ->method(
'getRequest')
94 ->will($this->returnValue($this->requestMock));
95 $this->customerSessionMock->expects($this->once())->method(
'isLoggedIn')->will($this->returnValue(
false));
97 ->expects($this->once())
98 ->method(
'getFullActionName')
99 ->will($this->returnValue(
'customer_account_logout'));
100 $this->helperMock->expects($this->once())->method(
'getLifeTime')->will($this->returnValue(60));
101 $this->customerSessionMock
102 ->expects($this->once())->method(
'getCookiePath')->will($this->returnValue(
'path/cookie'));
103 $this->sessionFactoryMock
104 ->expects($this->once())
106 ->will($this->returnValue($this->sessionMock));
107 $this->sessionMock->expects($this->once())->method(
'renewPersistentCookie')->with(60,
'path/cookie');
108 $this->model->execute($this->observerMock);
114 ->expects($this->once())
115 ->method(
'canProcess')
116 ->with($this->observerMock)
117 ->will($this->returnValue(
false));
118 $this->helperMock->expects($this->never())->method(
'isEnabled');
121 ->expects($this->never())
122 ->method(
'getEvent');
124 $this->model->execute($this->observerMock);
testRenewCookieWhenCannotProcessPersistentData()