@@ -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
+ protected $ cookieManager ;
80
+
81
+ /**
82
+ * @var \Magento\Framework\Stdlib\Cookie\CookieMetadataFactory| \PHPUnit_Framework_MockObject_MockObject
83
+ */
84
+ protected $ cookieMetadataFactory ;
85
+
86
+ /**
87
+ * @var \Magento\Framework\Stdlib\Cookie\CookieMetadata| \PHPUnit_Framework_MockObject_MockObject
88
+ */
89
+ protected $ cookieMetadata ;
90
+
76
91
protected function setUp ()
77
92
{
78
93
$ this ->request = $ this ->getMockBuilder (\Magento \Framework \App \Request \Http::class)
@@ -100,6 +115,16 @@ protected function setUp()
100
115
->setMethods (['create ' ])
101
116
->getMock ();
102
117
118
+ $ this ->cookieManager = $ this ->getMockBuilder (\Magento \Framework \Stdlib \CookieManagerInterface::class)
119
+ ->setMethods (['getCookie ' , 'deleteCookie ' ])
120
+ ->getMockForAbstractClass ();
121
+ $ this ->cookieMetadataFactory = $ this ->getMockBuilder (\Magento \Framework \Stdlib \Cookie \CookieMetadataFactory::class)
122
+ ->disableOriginalConstructor ()
123
+ ->getMock ();
124
+ $ this ->cookieMetadata = $ this ->getMockBuilder (\Magento \Framework \Stdlib \Cookie \CookieMetadata::class)
125
+ ->disableOriginalConstructor ()
126
+ ->getMock ();
127
+
103
128
$ this ->resultRaw = $ this ->getMockBuilder (\Magento \Framework \Controller \Result \Raw::class)
104
129
->disableOriginalConstructor ()
105
130
->getMock ();
@@ -128,6 +153,8 @@ protected function setUp()
128
153
'resultJsonFactory ' => $ this ->resultJsonFactory ,
129
154
'objectManager ' => $ this ->objectManager ,
130
155
'customerAccountManagement ' => $ this ->customerAccountManagementMock ,
156
+ 'cookieManager ' => $ this ->cookieManager ,
157
+ 'cookieMetadataFactory ' => $ this ->cookieMetadataFactory
131
158
]
132
159
);
133
160
}
@@ -179,6 +206,22 @@ public function testLogin()
179
206
$ this ->object ->setAccountRedirect ($ redirectMock );
180
207
$ redirectMock ->expects ($ this ->once ())->method ('getRedirectCookie ' )->willReturn ('some_url1 ' );
181
208
209
+ $ this ->cookieManager ->expects ($ this ->once ())
210
+ ->method ('getCookie ' )
211
+ ->with ('mage-cache-sessid ' )
212
+ ->willReturn (true );
213
+ $ this ->cookieMetadataFactory ->expects ($ this ->once ())
214
+ ->method ('createCookieMetadata ' )
215
+ ->willReturn ($ this ->cookieMetadata );
216
+ $ this ->cookieMetadata ->expects ($ this ->once ())
217
+ ->method ('setPath ' )
218
+ ->with ('/ ' )
219
+ ->willReturnSelf ();
220
+ $ this ->cookieManager ->expects ($ this ->once ())
221
+ ->method ('deleteCookie ' )
222
+ ->with ('mage-cache-sessid ' , $ this ->cookieMetadata )
223
+ ->willReturnSelf ();
224
+
182
225
$ scopeConfigMock = $ this ->createMock (\Magento \Framework \App \Config \ScopeConfigInterface::class);
183
226
$ this ->object ->setScopeConfig ($ scopeConfigMock );
184
227
$ scopeConfigMock ->expects ($ this ->once ())->method ('getValue ' )
0 commit comments