54 $this->actionMock = $this->createMock(\
Magento\Persistent\Controller\Index::class);
55 $this->observerMock = $this->createMock(\
Magento\Framework\Event\Observer::class);
56 $this->sessionHelperMock = $this->createMock(\
Magento\Persistent\Helper\Session::class);
57 $this->helperMock = $this->createMock(\
Magento\Persistent\Helper\Data::class);
58 $this->customerSessionMock = $this->createMock(\
Magento\Customer\Model\Session::class);
59 $this->quoteManagerMock = $this->createMock(\
Magento\Persistent\Model\QuoteManager::class);
60 $this->eventManagerMock =
61 $this->createPartialMock(\
Magento\Framework\Event::class, [
'getControllerAction',
'__wakeUp']);
63 ->expects($this->once())
65 ->will($this->returnValue($this->eventManagerMock));
66 $this->model = new \Magento\Persistent\Observer\MakePersistentQuoteGuestObserver(
67 $this->sessionHelperMock,
69 $this->customerSessionMock,
70 $this->quoteManagerMock
76 $this->eventManagerMock
77 ->expects($this->once())
78 ->method(
'getControllerAction')
79 ->will($this->returnValue($this->actionMock));
80 $this->sessionHelperMock->expects($this->once())->method(
'isPersistent')->will($this->returnValue(
true));
81 $this->customerSessionMock->expects($this->once())->method(
'isLoggedIn')->will($this->returnValue(
false));
82 $this->helperMock->expects($this->never())->method(
'isShoppingCartPersist');
83 $this->quoteManagerMock->expects($this->once())->method(
'setGuest')->with(
true);
84 $this->model->execute($this->observerMock);
89 $this->eventManagerMock
90 ->expects($this->once())
91 ->method(
'getControllerAction')
92 ->will($this->returnValue($this->actionMock));
93 $this->sessionHelperMock->expects($this->once())->method(
'isPersistent')->will($this->returnValue(
true));
94 $this->customerSessionMock->expects($this->once())->method(
'isLoggedIn')->will($this->returnValue(
true));
95 $this->helperMock->expects($this->once())->method(
'isShoppingCartPersist')->will($this->returnValue(
true));
96 $this->quoteManagerMock->expects($this->once())->method(
'setGuest')->with(
true);
97 $this->model->execute($this->observerMock);
102 $this->eventManagerMock
103 ->expects($this->once())
104 ->method(
'getControllerAction')
105 ->will($this->returnValue($this->actionMock));
106 $this->sessionHelperMock->expects($this->once())->method(
'isPersistent')->will($this->returnValue(
true));
107 $this->customerSessionMock->expects($this->once())->method(
'isLoggedIn')->will($this->returnValue(
true));
108 $this->helperMock->expects($this->once())->method(
'isShoppingCartPersist')->will($this->returnValue(
false));
109 $this->quoteManagerMock->expects($this->never())->method(
'setGuest');
110 $this->model->execute($this->observerMock);
testExecuteWhenShoppingCartIsNotPersist()
testExecuteWhenShoppingCartIsPersist()