@@ -73,6 +73,21 @@ class LoginTest extends \PHPUnit_Framework_TestCase
73
73
*/
74
74
protected $ redirectMock ;
75
75
76
+ /**
77
+ * @var \Magento\Framework\Stdlib\CookieManagerInterface| \PHPUnit_Framework_MockObject_MockObject
78
+ */
79
+ private $ cookieManager ;
80
+
81
+ /**
82
+ * @var \Magento\Framework\Stdlib\Cookie\CookieMetadataFactory| \PHPUnit_Framework_MockObject_MockObject
83
+ */
84
+ private $ cookieMetadataFactory ;
85
+
86
+ /**
87
+ * @var \Magento\Framework\Stdlib\Cookie\CookieMetadata| \PHPUnit_Framework_MockObject_MockObject
88
+ */
89
+ private $ cookieMetadata ;
90
+
76
91
protected function setUp ()
77
92
{
78
93
$ this ->request = $ this ->getMockBuilder ('Magento\Framework\App\Request\Http ' )
@@ -105,14 +120,13 @@ protected function setUp()
105
120
'' ,
106
121
false
107
122
);
108
- $ this ->customerAccountManagementMock =
109
- $ this ->getMock (
110
- '\Magento\Customer\Model\AccountManagement ' ,
111
- ['authenticate ' ],
112
- [],
113
- '' ,
114
- false
115
- );
123
+ $ this ->customerAccountManagementMock = $ this ->getMock (
124
+ '\Magento\Customer\Model\AccountManagement ' ,
125
+ ['authenticate ' ],
126
+ [],
127
+ '' ,
128
+ false
129
+ );
116
130
117
131
$ this ->jsonHelperMock = $ this ->getMock (
118
132
'\Magento\Framework\Json\Helper\Data ' ,
@@ -130,6 +144,16 @@ protected function setUp()
130
144
->setMethods (['create ' ])
131
145
->getMock ();
132
146
147
+ $ this ->cookieManager = $ this ->getMockBuilder (\Magento \Framework \Stdlib \CookieManagerInterface::class)
148
+ ->setMethods (['getCookie ' , 'deleteCookie ' ])
149
+ ->getMockForAbstractClass ();
150
+ $ this ->cookieMetadataFactory = $ this ->getMockBuilder (\Magento \Framework \Stdlib \Cookie \CookieMetadataFactory::class)
151
+ ->disableOriginalConstructor ()
152
+ ->getMock ();
153
+ $ this ->cookieMetadata = $ this ->getMockBuilder (\Magento \Framework \Stdlib \Cookie \CookieMetadata::class)
154
+ ->disableOriginalConstructor ()
155
+ ->getMock ();
156
+
133
157
$ this ->resultRaw = $ this ->getMockBuilder ('Magento\Framework\Controller\Result\Raw ' )
134
158
->disableOriginalConstructor ()
135
159
->getMock ();
@@ -158,6 +182,8 @@ protected function setUp()
158
182
'resultJsonFactory ' => $ this ->resultJsonFactory ,
159
183
'objectManager ' => $ this ->objectManager ,
160
184
'customerAccountManagement ' => $ this ->customerAccountManagementMock ,
185
+ 'cookieManager ' => $ this ->cookieManager ,
186
+ 'cookieMetadataFactory ' => $ this ->cookieMetadataFactory
161
187
]
162
188
);
163
189
}
@@ -209,6 +235,22 @@ public function testLogin()
209
235
$ this ->object ->setAccountRedirect ($ redirectMock );
210
236
$ redirectMock ->expects ($ this ->once ())->method ('getRedirectCookie ' )->willReturn ('some_url1 ' );
211
237
238
+ $ this ->cookieManager ->expects ($ this ->once ())
239
+ ->method ('getCookie ' )
240
+ ->with ('mage-cache-sessid ' )
241
+ ->willReturn (true );
242
+ $ this ->cookieMetadataFactory ->expects ($ this ->once ())
243
+ ->method ('createCookieMetadata ' )
244
+ ->willReturn ($ this ->cookieMetadata );
245
+ $ this ->cookieMetadata ->expects ($ this ->once ())
246
+ ->method ('setPath ' )
247
+ ->with ('/ ' )
248
+ ->willReturnSelf ();
249
+ $ this ->cookieManager ->expects ($ this ->once ())
250
+ ->method ('deleteCookie ' )
251
+ ->with ('mage-cache-sessid ' , $ this ->cookieMetadata )
252
+ ->willReturnSelf ();
253
+
212
254
$ scopeConfigMock = $ this ->getMock (\Magento \Framework \App \Config \ScopeConfigInterface::class);
213
255
$ this ->object ->setScopeConfig ($ scopeConfigMock );
214
256
$ scopeConfigMock ->expects ($ this ->once ())->method ('getValue ' )
0 commit comments