4
4
* See COPYING.txt for license details.
5
5
*/
6
6
namespace Magento \Test \TestCase ;
7
+ use Magento \Framework \Stdlib \CookieManagerInterface ;
7
8
8
9
/**
9
10
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
@@ -15,11 +16,15 @@ class ControllerAbstractTest extends \Magento\TestFramework\TestCase\AbstractCon
15
16
/** @var \PHPUnit_Framework_MockObject_MockObject | \Magento\Framework\Message\Manager */
16
17
private $ messageManager ;
17
18
19
+ /** @var \PHPUnit_Framework_MockObject_MockObject | CookieManagerInterface */
20
+ private $ cookieManagerMock ;
21
+
18
22
protected function setUp ()
19
23
{
20
24
$ testObjectManager = new \Magento \Framework \TestFramework \Unit \Helper \ObjectManager ($ this );
21
25
22
26
$ this ->messageManager = $ this ->getMock ('\Magento\Framework\Message\Manager ' , [], [], '' , false );
27
+ $ this ->cookieManagerMock = $ this ->getMock (CookieManagerInterface::class, [], [], '' , false );
23
28
$ request = $ testObjectManager ->getObject ('Magento\TestFramework\Request ' );
24
29
$ response = $ testObjectManager ->getObject ('Magento\TestFramework\Response ' );
25
30
$ this ->_objectManager = $ this ->getMock (
@@ -37,6 +42,7 @@ protected function setUp()
37
42
['Magento\Framework\App\RequestInterface ' , $ request ],
38
43
['Magento\Framework\App\ResponseInterface ' , $ response ],
39
44
['Magento\Framework\Message\Manager ' , $ this ->messageManager ],
45
+ [CookieManagerInterface::class, $ this ->cookieManagerMock ],
40
46
]
41
47
)
42
48
);
@@ -139,16 +145,20 @@ public function testAssertSessionMessagesSuccess(array $expectedMessages, $messa
139
145
public function assertSessionMessagesDataProvider ()
140
146
{
141
147
return [
142
- 'message waning type filtering ' => [
143
- ['some_warning ' ],
148
+ 'message warning type filtering ' => [
149
+ ['some_warning ' , ' warning_cookie ' ],
144
150
\Magento \Framework \Message \MessageInterface::TYPE_WARNING ,
145
151
],
146
152
'message error type filtering ' => [
147
- ['error_one ' , 'error_two ' ],
153
+ ['error_one ' , 'error_two ' , ' error_cookie ' ],
148
154
\Magento \Framework \Message \MessageInterface::TYPE_ERROR ,
149
155
],
156
+ 'message notice type filtering ' => [
157
+ ['some_notice ' , 'notice_cookie ' ],
158
+ \Magento \Framework \Message \MessageInterface::TYPE_NOTICE ,
159
+ ],
150
160
'message success type filtering ' => [
151
- ['success! ' ],
161
+ ['success! ' , ' success_cookie ' ],
152
162
\Magento \Framework \Message \MessageInterface::TYPE_SUCCESS ,
153
163
],
154
164
];
@@ -166,6 +176,10 @@ public function testAssertSessionMessagesAll()
166
176
'error_two ' ,
167
177
'some_notice ' ,
168
178
'success! ' ,
179
+ 'warning_cookie ' ,
180
+ 'notice_cookie ' ,
181
+ 'success_cookie ' ,
182
+ 'error_cookie ' ,
169
183
]
170
184
)
171
185
);
@@ -192,5 +206,28 @@ private function addSessionMessages()
192
206
->addMessage (new \Magento \Framework \Message \Success ('success! ' ));
193
207
$ this ->messageManager ->expects ($ this ->any ())->method ('getMessages ' )
194
208
->will ($ this ->returnValue ($ messagesCollection ));
209
+
210
+ $ cookieMessages = [
211
+ [
212
+ 'type ' => 'warning ' ,
213
+ 'text ' => 'warning_cookie ' ,
214
+ ],
215
+ [
216
+ 'type ' => 'notice ' ,
217
+ 'text ' => 'notice_cookie ' ,
218
+ ],
219
+ [
220
+ 'type ' => 'success ' ,
221
+ 'text ' => 'success_cookie ' ,
222
+ ],
223
+ [
224
+ 'type ' => 'error ' ,
225
+ 'text ' => 'error_cookie ' ,
226
+ ],
227
+ ];
228
+
229
+ $ this ->cookieManagerMock ->expects ($ this ->any ())
230
+ ->method ('getCookie ' )
231
+ ->willReturn (\Zend_Json::encode ($ cookieMessages ));
195
232
}
196
233
}
0 commit comments