@@ -111,7 +111,7 @@ public function testGetAccessToken()
111111 $ this ->assertNull ($ token ->getResourceOwnerId ());
112112 }
113113
114- public function testUserDataWithoutImage ()
114+ public function testUserData ()
115115 {
116116 $ email = uniqid ();
117117 $ firstname = uniqid ();
@@ -128,14 +128,10 @@ public function testUserDataWithoutImage()
128128 $ userResponse ->shouldReceive ('getBody ' )->andReturn ('{"id": ' .$ userId .', "name": " ' .$ name .'", "first_name": " ' .$ firstname .'", "last_name": " ' .$ lastname .'", "emails": {"preferred": " ' .$ email .'"}, "link": " ' .$ urls .'"} ' );
129129 $ userResponse ->shouldReceive ('getHeader ' )->andReturn (['content-type ' => 'json ' ]);
130130
131- $ imageResponse = m::mock ('Psr\Http\Message\ResponseInterface ' );
132- $ imageResponse ->shouldReceive ('getBody ' )->andReturn ('{} ' );
133- $ imageResponse ->shouldReceive ('getHeader ' )->andReturn (['content-type ' => 'json ' ]);
134-
135131 $ client = m::mock ('GuzzleHttp\ClientInterface ' );
136132 $ client ->shouldReceive ('send ' )
137- ->times (3 )
138- ->andReturn ($ postResponse , $ userResponse, $ imageResponse );
133+ ->times (2 )
134+ ->andReturn ($ postResponse , $ userResponse );
139135 $ this ->provider ->setHttpClient ($ client );
140136
141137 $ token = $ this ->provider ->getAccessToken ('authorization_code ' , ['code ' => 'mock_authorization_code ' ]);
@@ -153,47 +149,6 @@ public function testUserDataWithoutImage()
153149 $ this ->assertEquals ($ userId , $ user ->toArray ()['id ' ]);
154150 $ this ->assertEquals ($ urls .'/cid- ' .$ userId , $ user ->getUrls ());
155151 $ this ->assertEquals ($ urls .'/cid- ' .$ userId , $ user ->toArray ()['link ' ].'/cid- ' .$ user ->toArray ()['id ' ]);
156- $ this ->assertNull ($ user ->getImageurl ());
157- }
158-
159- public function testUserDataWithImage ()
160- {
161- $ email = uniqid ();
162- $ firstname = uniqid ();
163- $ imageurl = uniqid ();
164- $ lastname = uniqid ();
165- $ name = uniqid ();
166- $ userId = rand (1000 ,9999 );
167- $ urls = uniqid ();
168-
169- $ postResponse = m::mock ('Psr\Http\Message\ResponseInterface ' );
170- $ postResponse ->shouldReceive ('getBody ' )->andReturn ('{"access_token": "mock_access_token", "expires": 3600, "refresh_token": "mock_refresh_token", "uid": ' .$ userId .'} ' );
171- $ postResponse ->shouldReceive ('getHeader ' )->andReturn (['content-type ' => 'json ' ]);
172-
173- $ userResponse = m::mock ('Psr\Http\Message\ResponseInterface ' );
174- $ userResponse ->shouldReceive ('getBody ' )->andReturn ('{"id": ' .$ userId .', "name": " ' .$ name .'", "first_name": " ' .$ firstname .'", "last_name": " ' .$ lastname .'", "emails": {"preferred": " ' .$ email .'"}, "link": " ' .$ urls .'"} ' );
175- $ userResponse ->shouldReceive ('getHeader ' )->andReturn (['content-type ' => 'json ' ]);
176-
177- $ imageResponse = m::mock ('Psr\Http\Message\ResponseInterface ' );
178- $ imageResponse ->shouldReceive ('getBody ' )->andReturn ('{"url":" ' .$ imageurl .'"} ' );
179- $ imageResponse ->shouldReceive ('getHeader ' )->andReturn (['content-type ' => 'json ' ]);
180-
181- $ client = m::mock ('GuzzleHttp\ClientInterface ' );
182- $ client ->shouldReceive ('send ' )
183- ->times (3 )
184- ->andReturn ($ postResponse , $ userResponse , $ imageResponse );
185- $ this ->provider ->setHttpClient ($ client );
186-
187- $ token = $ this ->provider ->getAccessToken ('authorization_code ' , ['code ' => 'mock_authorization_code ' ]);
188- $ user = $ this ->provider ->getResourceOwner ($ token );
189-
190- $ this ->assertEquals ($ email , $ user ->getEmail ());
191- $ this ->assertEquals ($ firstname , $ user ->getFirstname ());
192- $ this ->assertEquals ($ imageurl , $ user ->getImageurl ());
193- $ this ->assertEquals ($ lastname , $ user ->getLastname ());
194- $ this ->assertEquals ($ name , $ user ->getName ());
195- $ this ->assertEquals ($ userId , $ user ->getId ());
196- $ this ->assertEquals ($ urls .'/cid- ' .$ userId , $ user ->getUrls ());
197152 }
198153
199154 /**
0 commit comments