62 $this->context = $this->createMock(\
Magento\Framework\
App\Action\Context::class);
63 $this->wishlistProvider = $this->createMock(\
Magento\
Wishlist\Controller\WishlistProvider::class);
64 $this->itemCarrier = $this->createMock(\
Magento\
Wishlist\Model\ItemCarrier::class);
65 $this->formKeyValidator = $this->createMock(\
Magento\Framework\
Data\Form\FormKey\Validator::class);
66 $this->request = $this->createMock(\
Magento\Framework\
App\Request\Http::class);
68 $this->resultFactoryMock = $this->getMockBuilder(\
Magento\Framework\Controller\ResultFactory::class)
69 ->disableOriginalConstructor()
71 $this->resultRedirectMock = $this->getMockBuilder(\
Magento\Framework\Controller\Result\Redirect::class)
72 ->disableOriginalConstructor()
74 $this->resultForwardMock = $this->getMockBuilder(\
Magento\Framework\Controller\Result\Forward::class)
75 ->disableOriginalConstructor()
78 $this->resultFactoryMock->expects($this->any())
90 $om = $this->createMock(\
Magento\Framework\
App\ObjectManager::class);
91 $eventManager = $this->createMock(\
Magento\Framework\
Event\Manager::class);
92 $url = $this->createMock(\
Magento\Framework\Url::class);
93 $actionFlag = $this->createMock(\
Magento\Framework\
App\ActionFlag::class);
95 $view = $this->createMock(\
Magento\Framework\
App\View::class);
96 $messageManager = $this->createMock(\
Magento\Framework\Message\Manager::class);
99 ->expects($this->any())
100 ->method(
'getObjectManager')
101 ->will($this->returnValue(
$om));
103 ->expects($this->any())
104 ->method(
'getRequest')
105 ->will($this->returnValue($this->request));
107 ->expects($this->any())
108 ->method(
'getResponse')
109 ->will($this->returnValue($this->response));
111 ->expects($this->any())
112 ->method(
'getEventManager')
113 ->will($this->returnValue($eventManager));
115 ->expects($this->any())
117 ->will($this->returnValue(
$url));
119 ->expects($this->any())
120 ->method(
'getActionFlag')
121 ->will($this->returnValue($actionFlag));
123 ->expects($this->any())
124 ->method(
'getRedirect')
125 ->will($this->returnValue($redirect));
127 ->expects($this->any())
129 ->will($this->returnValue($view));
131 ->expects($this->any())
132 ->method(
'getMessageManager')
133 ->will($this->returnValue($messageManager));
134 $this->context->expects($this->any())
135 ->method(
'getResultFactory')
136 ->willReturn($this->resultFactoryMock);
145 return new \Magento\Wishlist\Controller\Index\Allcart(
147 $this->wishlistProvider,
148 $this->formKeyValidator,
155 $this->formKeyValidator
156 ->expects($this->once())
158 ->with($this->request)
159 ->will($this->returnValue(
false));
160 $this->resultForwardMock->expects($this->once())
166 $this->assertSame($this->resultForwardMock,
$controller->execute());
171 $this->formKeyValidator
172 ->expects($this->once())
174 ->with($this->request)
175 ->will($this->returnValue(
true));
176 $this->wishlistProvider
177 ->expects($this->once())
178 ->method(
'getWishlist')
179 ->will($this->returnValue(
null));
180 $this->resultForwardMock->expects($this->once())
185 $this->assertSame($this->resultForwardMock, $this->
getController()->execute());
190 $url =
'http://redirect-url.com';
193 $this->formKeyValidator->expects($this->once())
195 ->with($this->request)
196 ->will($this->returnValue(
true));
197 $this->request->expects($this->once())
200 ->will($this->returnValue(2));
201 $this->wishlistProvider->expects($this->once())
202 ->method(
'getWishlist')
204 $this->itemCarrier->expects($this->once())
205 ->method(
'moveAllToCart')
208 $this->resultRedirectMock->expects($this->once())
213 $this->assertSame($this->resultRedirectMock, $this->
getController()->execute());
testExecuteInvalidFormKey()
testExecuteWithoutWishlist()