9
9
namespace Magento \AdobeIms \Test \Unit \Model ;
10
10
11
11
use Exception ;
12
+ use Magento \AdobeIms \Model \GetProfile ;
12
13
use Magento \AdobeIms \Model \LogOut ;
14
+ use Magento \Backend \Model \Auth \StorageInterface ;
13
15
use Magento \AdobeImsApi \Api \ConfigInterface ;
14
- use Magento \AdobeImsApi \Api \Data \UserProfileInterface ;
15
16
use Magento \AdobeImsApi \Api \FlushUserTokensInterface ;
16
17
use Magento \AdobeImsApi \Api \GetAccessTokenInterface ;
17
- use Magento \AdobeImsApi \Api \UserProfileRepositoryInterface ;
18
- use Magento \Authorization \Model \UserContextInterface ;
18
+ use Magento \Backend \Model \Auth ;
19
19
use Magento \Framework \HTTP \Client \Curl ;
20
20
use Magento \Framework \HTTP \Client \CurlFactory ;
21
21
use PHPUnit \Framework \MockObject \MockObject ;
@@ -60,6 +60,16 @@ class LogOutTest extends TestCase
60
60
*/
61
61
private $ model ;
62
62
63
+ /**
64
+ * @var Auth|MockObject
65
+ */
66
+ private $ auth ;
67
+
68
+ /**
69
+ * @var GetProfile|MockObject
70
+ */
71
+ private $ profile ;
72
+
63
73
/**
64
74
* @inheritdoc
65
75
*/
@@ -70,12 +80,16 @@ protected function setUp(): void
70
80
$ this ->loggerInterfaceMock = $ this ->createMock (LoggerInterface::class);
71
81
$ this ->getToken = $ this ->createMock (GetAccessTokenInterface::class);
72
82
$ this ->flushTokens = $ this ->createMock (FlushUserTokensInterface::class);
83
+ $ this ->profile = $ this ->createMock (GetProfile::class);
84
+ $ this ->auth = $ this ->createMock (Auth::class);
73
85
$ this ->model = new LogOut (
74
86
$ this ->loggerInterfaceMock ,
75
87
$ this ->configInterfaceMock ,
76
88
$ this ->curlFactoryMock ,
77
89
$ this ->getToken ,
78
- $ this ->flushTokens
90
+ $ this ->flushTokens ,
91
+ $ this ->profile ,
92
+ $ this ->auth
79
93
);
80
94
}
81
95
@@ -104,7 +118,15 @@ public function testExecute(): void
104
118
105
119
$ this ->flushTokens ->expects ($ this ->once ())
106
120
->method ('execute ' );
107
-
121
+ $ session = $ this ->getMockBuilder (StorageInterface::class)
122
+ ->addMethods (['getAdobeAccessToken ' ])
123
+ ->getMockForAbstractClass ();
124
+ $ session ->expects ($ this ->once ())
125
+ ->method ('getAdobeAccessToken ' )
126
+ ->willReturn (null );
127
+ $ this ->auth ->expects ($ this ->once ())
128
+ ->method ('getAuthStorage ' )
129
+ ->willReturn ($ session );
108
130
$ this ->assertEquals (true , $ this ->model ->execute ());
109
131
}
110
132
@@ -135,7 +157,15 @@ public function testExecuteWithError(): void
135
157
136
158
$ this ->flushTokens ->expects ($ this ->never ())
137
159
->method ('execute ' );
138
-
160
+ $ session = $ this ->getMockBuilder (StorageInterface::class)
161
+ ->addMethods (['getAdobeAccessToken ' ])
162
+ ->getMockForAbstractClass ();
163
+ $ session ->expects ($ this ->once ())
164
+ ->method ('getAdobeAccessToken ' )
165
+ ->willReturn (null );
166
+ $ this ->auth ->expects ($ this ->once ())
167
+ ->method ('getAuthStorage ' )
168
+ ->willReturn ($ session );
139
169
$ this ->assertEquals (false , $ this ->model ->execute ());
140
170
}
141
171
@@ -161,7 +191,15 @@ public function testExecuteWithException(): void
161
191
$ curl ->expects ($ this ->once ())
162
192
->method ('getStatus ' )
163
193
->willReturn (self ::HTTP_FOUND );
164
-
194
+ $ session = $ this ->getMockBuilder (StorageInterface::class)
195
+ ->addMethods (['getAdobeAccessToken ' ])
196
+ ->getMockForAbstractClass ();
197
+ $ session ->expects ($ this ->once ())
198
+ ->method ('getAdobeAccessToken ' )
199
+ ->willReturn (null );
200
+ $ this ->auth ->expects ($ this ->once ())
201
+ ->method ('getAuthStorage ' )
202
+ ->willReturn ($ session );
165
203
$ this ->flushTokens ->expects ($ this ->once ())
166
204
->method ('execute ' )
167
205
->willThrowException (new Exception ('Could not save user profile. ' ));
0 commit comments