Merge pull request #175 from jildertmiedema/guzzle-5
Upgrading to Guzzle 5, for oauth2-client 1.01.0
commit
511139edbe
|
@ -4,7 +4,7 @@
|
|||
"license": "MIT",
|
||||
"require": {
|
||||
"php": ">=5.4.0",
|
||||
"guzzle/guzzle": "~3.7"
|
||||
"guzzlehttp/guzzle": "~5.0"
|
||||
},
|
||||
"require-dev": {
|
||||
"phpunit/phpunit": "~4.0",
|
||||
|
|
|
@ -3,8 +3,8 @@
|
|||
namespace League\OAuth2\Client\Provider;
|
||||
|
||||
use Closure;
|
||||
use Guzzle\Http\Exception\BadResponseException;
|
||||
use Guzzle\Service\Client as GuzzleClient;
|
||||
use GuzzleHttp\Client as GuzzleClient;
|
||||
use GuzzleHttp\Exception\BadResponseException;
|
||||
use League\OAuth2\Client\Exception\IDPException as IDPException;
|
||||
use League\OAuth2\Client\Grant\GrantInterface;
|
||||
use League\OAuth2\Client\Token\AccessToken as AccessToken;
|
||||
|
@ -181,8 +181,11 @@ abstract class AbstractProvider implements ProviderInterface
|
|||
// @codeCoverageIgnoreEnd
|
||||
case 'POST':
|
||||
$client = $this->getHttpClient();
|
||||
$client->setBaseUrl($this->urlAccessToken());
|
||||
$request = $client->post(null, null, $requestParams)->send();
|
||||
$url = $this->urlAccessToken();
|
||||
$options = [
|
||||
'body' => $requestParams
|
||||
];
|
||||
$request = $client->post($url, $options);
|
||||
$response = $request->getBody();
|
||||
break;
|
||||
// @codeCoverageIgnoreStart
|
||||
|
@ -203,6 +206,7 @@ abstract class AbstractProvider implements ProviderInterface
|
|||
break;
|
||||
case 'string':
|
||||
parse_str($response, $result);
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -293,13 +297,14 @@ abstract class AbstractProvider implements ProviderInterface
|
|||
|
||||
try {
|
||||
$client = $this->getHttpClient();
|
||||
$client->setBaseUrl($url);
|
||||
|
||||
$options = [];
|
||||
|
||||
if ($this->headers) {
|
||||
$client->setDefaultOption('headers', $this->headers);
|
||||
$options['headers'] = $this->headers;
|
||||
}
|
||||
|
||||
$request = $client->get()->send();
|
||||
$request = $client->get($url, $options);
|
||||
$response = $request->getBody();
|
||||
} catch (BadResponseException $e) {
|
||||
// @codeCoverageIgnoreStart
|
||||
|
|
|
@ -27,8 +27,9 @@ class Facebook extends AbstractProvider
|
|||
public function userDetails($response, \League\OAuth2\Client\Token\AccessToken $token)
|
||||
{
|
||||
$client = $this->getHttpClient();
|
||||
$client->setBaseUrl('https://graph.facebook.com/me/picture?type=normal&access_token='.$token->accessToken);
|
||||
$request = $client->get()->send();
|
||||
$url = 'https://graph.facebook.com/me/picture?type=normal&access_token=' . $token->accessToken;
|
||||
$request = $client->get($url);
|
||||
|
||||
$info = $request->getInfo();
|
||||
$imageUrl = $info['url'];
|
||||
|
||||
|
|
|
@ -28,8 +28,8 @@ class Microsoft extends AbstractProvider
|
|||
public function userDetails($response, AccessToken $token)
|
||||
{
|
||||
$client = $this->getHttpClient();
|
||||
$client->setBaseUrl('https://apis.live.net/v5.0/'.$response->id.'/picture');
|
||||
$request = $client->get()->send();
|
||||
$url = 'https://apis.live.net/v5.0/' . $response->id . '/picture';
|
||||
$request = $client->get($url);
|
||||
$info = $request->getInfo();
|
||||
$imageUrl = $info['url'];
|
||||
|
||||
|
|
|
@ -25,12 +25,11 @@ class ClientCredentialsTest extends \PHPUnit_Framework_TestCase
|
|||
|
||||
public function testGetAccessToken()
|
||||
{
|
||||
$response = m::mock('Guzzle\Http\Message\Response');
|
||||
$response = m::mock('GuzzleHttp\Message\Response');
|
||||
$response->shouldReceive('getBody')->times(1)->andReturn('{"access_token": "mock_access_token", "expires": 3600, "refresh_token": "mock_refresh_token", "uid": 1}');
|
||||
|
||||
$client = m::mock('Guzzle\Service\Client');
|
||||
$client->shouldReceive('setBaseUrl')->times(1);
|
||||
$client->shouldReceive('post->send')->times(1)->andReturn($response);
|
||||
$client = m::mock('GuzzleHttp\Client');
|
||||
$client->shouldReceive('post')->times(1)->andReturn($response);
|
||||
$this->provider->setHttpClient($client);
|
||||
|
||||
$token = $this->provider->getAccessToken('client_credentials');
|
||||
|
|
|
@ -25,12 +25,11 @@ class PasswordTest extends \PHPUnit_Framework_TestCase
|
|||
|
||||
public function testGetAccessToken()
|
||||
{
|
||||
$response = m::mock('Guzzle\Http\Message\Response');
|
||||
$response = m::mock('GuzzleHttp\Message\Response');
|
||||
$response->shouldReceive('getBody')->times(1)->andReturn('{"access_token": "mock_access_token", "expires": 3600, "refresh_token": "mock_refresh_token", "uid": 1}');
|
||||
|
||||
$client = m::mock('Guzzle\Service\Client');
|
||||
$client->shouldReceive('setBaseUrl')->times(1);
|
||||
$client->shouldReceive('post->send')->times(1)->andReturn($response);
|
||||
$client = m::mock('GuzzleHttp\Client');
|
||||
$client->shouldReceive('post')->times(1)->andReturn($response);
|
||||
$this->provider->setHttpClient($client);
|
||||
|
||||
$token = $this->provider->getAccessToken('password', array('username' => 'mock_username', 'password' => 'mock_password'));
|
||||
|
|
|
@ -25,12 +25,11 @@ class RefreshTokenTest extends \PHPUnit_Framework_TestCase
|
|||
|
||||
public function testGetAccessToken()
|
||||
{
|
||||
$response = m::mock('Guzzle\Http\Message\Response');
|
||||
$response = m::mock('GuzzleHttp\Message\Response');
|
||||
$response->shouldReceive('getBody')->times(2)->andReturn('{"access_token": "mock_access_token", "expires": 3600, "refresh_token": "mock_refresh_token", "uid": 1}');
|
||||
|
||||
$client = m::mock('Guzzle\Service\Client');
|
||||
$client->shouldReceive('setBaseUrl')->times(2);
|
||||
$client->shouldReceive('post->send')->times(2)->andReturn($response);
|
||||
$client = m::mock('GuzzleHttp\Client');
|
||||
$client->shouldReceive('post')->times(2)->andReturn($response);
|
||||
$this->provider->setHttpClient($client);
|
||||
|
||||
$token = $this->provider->getAccessToken('authorization_code', ['code' => 'mock_authorization_code']);
|
||||
|
@ -48,12 +47,11 @@ class RefreshTokenTest extends \PHPUnit_Framework_TestCase
|
|||
*/
|
||||
public function testInvalidRefreshToken()
|
||||
{
|
||||
$response = m::mock('Guzzle\Http\Message\Response');
|
||||
$response = m::mock('GuzzleHttp\Message\Response');
|
||||
$response->shouldReceive('getBody')->times(1)->andReturn('{"access_token": "mock_access_token", "expires": 3600, "refresh_token": "mock_refresh_token", "uid": 1}');
|
||||
|
||||
$client = m::mock('Guzzle\Service\Client');
|
||||
$client->shouldReceive('setBaseUrl')->times(1);
|
||||
$client->shouldReceive('post->send')->times(1)->andReturn($response);
|
||||
$client = m::mock('GuzzleHttp\Client');
|
||||
$client->shouldReceive('post')->times(1)->andReturn($response);
|
||||
$this->provider->setHttpClient($client);
|
||||
|
||||
$token = $this->provider->getAccessToken('authorization_code', ['code' => 'mock_authorization_code']);
|
||||
|
|
|
@ -48,12 +48,11 @@ class EventbriteTest extends \PHPUnit_Framework_TestCase
|
|||
|
||||
public function testGetAccessToken()
|
||||
{
|
||||
$response = m::mock('Guzzle\Http\Message\Response');
|
||||
$response = m::mock('GuzzleHttp\Message\Response');
|
||||
$response->shouldReceive('getBody')->times(1)->andReturn('{"access_token": "mock_access_token", "expires": 3600, "refresh_token": "mock_refresh_token", "uid": 1}');
|
||||
|
||||
$client = m::mock('Guzzle\Service\Client');
|
||||
$client->shouldReceive('setBaseUrl')->times(1);
|
||||
$client->shouldReceive('post->send')->times(1)->andReturn($response);
|
||||
$client = m::mock('GuzzleHttp\Client');
|
||||
$client->shouldReceive('post')->times(1)->andReturn($response);
|
||||
$this->provider->setHttpClient($client);
|
||||
|
||||
$token = $this->provider->getAccessToken('authorization_code', ['code' => 'mock_authorization_code']);
|
||||
|
@ -72,17 +71,16 @@ class EventbriteTest extends \PHPUnit_Framework_TestCase
|
|||
|
||||
public function testUserData()
|
||||
{
|
||||
$postResponse = m::mock('Guzzle\Http\Message\Response');
|
||||
$postResponse = m::mock('GuzzleHttp\Message\Response');
|
||||
$postResponse->shouldReceive('getBody')->times(1)->andReturn('{"access_token": "mock_access_token", "expires": 3600, "refresh_token": "mock_refresh_token", "uid": 1}');
|
||||
|
||||
$getResponse = m::mock('Guzzle\Http\Message\Response');
|
||||
$getResponse = m::mock('GuzzleHttp\Message\Response');
|
||||
$getResponse->shouldReceive('getBody')->times(4)->andReturn('{"user": {"user_id": 12345, "email": "mock_email"}}');
|
||||
|
||||
$client = m::mock('Guzzle\Service\Client');
|
||||
$client->shouldReceive('setBaseUrl')->times(5);
|
||||
$client->shouldReceive('post->send')->times(1)->andReturn($postResponse);
|
||||
$client->shouldReceive('get->send')->times(4)->andReturn($getResponse);
|
||||
$client->shouldReceive('setDefaultOption')->times(4);
|
||||
$client = m::mock('GuzzleHttp\Client');
|
||||
$client->shouldReceive('post')->times(1)->andReturn($postResponse);
|
||||
$client->shouldReceive('get')->times(4)->andReturn($getResponse);
|
||||
|
||||
$this->provider->setHttpClient($client);
|
||||
|
||||
$token = $this->provider->getAccessToken('authorization_code', ['code' => 'mock_authorization_code']);
|
||||
|
|
|
@ -48,12 +48,11 @@ class FacebookTest extends \PHPUnit_Framework_TestCase
|
|||
|
||||
public function testGetAccessToken()
|
||||
{
|
||||
$response = m::mock('Guzzle\Http\Message\Response');
|
||||
$response = m::mock('GuzzleHttp\Message\Response');
|
||||
$response->shouldReceive('getBody')->times(1)->andReturn('access_token=mock_access_token&expires=3600&refresh_token=mock_refresh_token&uid=1');
|
||||
|
||||
$client = m::mock('Guzzle\Service\Client');
|
||||
$client->shouldReceive('setBaseUrl')->times(1);
|
||||
$client->shouldReceive('post->send')->times(1)->andReturn($response);
|
||||
$client = m::mock('GuzzleHttp\Client');
|
||||
$client->shouldReceive('post')->times(1)->andReturn($response);
|
||||
$this->provider->setHttpClient($client);
|
||||
|
||||
$token = $this->provider->getAccessToken('authorization_code', ['code' => 'mock_authorization_code']);
|
||||
|
@ -74,17 +73,17 @@ class FacebookTest extends \PHPUnit_Framework_TestCase
|
|||
|
||||
public function testUserData()
|
||||
{
|
||||
$postResponse = m::mock('Guzzle\Http\Message\Response');
|
||||
$postResponse = m::mock('GuzzleHttp\Message\Response');
|
||||
$postResponse->shouldReceive('getBody')->times(1)->andReturn('access_token=mock_access_token&expires=3600&refresh_token=mock_refresh_token&uid=1');
|
||||
|
||||
$getResponse = m::mock('Guzzle\Http\Message\Response');
|
||||
$getResponse = m::mock('GuzzleHttp\Message\Response');
|
||||
$getResponse->shouldReceive('getBody')->andReturn('{"id": 12345, "name": "mock_name", "username": "mock_username", "first_name": "mock_first_name", "last_name": "mock_last_name", "email": "mock_email", "Location": "mock_home", "bio": "mock_description", "link": "mock_facebook_url"}');
|
||||
$getResponse->shouldReceive('getInfo')->andReturn(['url' => 'mock_image_url']);
|
||||
|
||||
$client = m::mock('Guzzle\Service\Client');
|
||||
$client->shouldReceive('setBaseUrl')->times(6);
|
||||
$client->shouldReceive('post->send')->times(1)->andReturn($postResponse);
|
||||
$client->shouldReceive('get->send')->andReturn($getResponse);
|
||||
$client = m::mock('GuzzleHttp\Client');
|
||||
$client->shouldReceive('post')->times(1)->andReturn($postResponse);
|
||||
$client->shouldReceive('get')->andReturn($getResponse);
|
||||
|
||||
$this->provider->setHttpClient($client);
|
||||
|
||||
$token = $this->provider->getAccessToken('authorization_code', ['code' => 'mock_authorization_code']);
|
||||
|
|
|
@ -48,12 +48,11 @@ class GithubTest extends \PHPUnit_Framework_TestCase
|
|||
|
||||
public function testGetAccessToken()
|
||||
{
|
||||
$response = m::mock('Guzzle\Http\Message\Response');
|
||||
$response = m::mock('GuzzleHttp\Message\Response');
|
||||
$response->shouldReceive('getBody')->times(1)->andReturn('access_token=mock_access_token&expires=3600&refresh_token=mock_refresh_token&uid=1');
|
||||
|
||||
$client = m::mock('Guzzle\Service\Client');
|
||||
$client->shouldReceive('setBaseUrl')->times(1);
|
||||
$client->shouldReceive('post->send')->times(1)->andReturn($response);
|
||||
$client = m::mock('GuzzleHttp\Client');
|
||||
$client->shouldReceive('post')->times(1)->andReturn($response);
|
||||
$this->provider->setHttpClient($client);
|
||||
|
||||
$token = $this->provider->getAccessToken('authorization_code', ['code' => 'mock_authorization_code']);
|
||||
|
@ -69,12 +68,11 @@ class GithubTest extends \PHPUnit_Framework_TestCase
|
|||
{
|
||||
$this->provider->uidKey = 'otherKey';
|
||||
|
||||
$response = m::mock('Guzzle\Http\Message\Response');
|
||||
$response = m::mock('GuzzleHttp\Message\Response');
|
||||
$response->shouldReceive('getBody')->times(1)->andReturn('access_token=mock_access_token&expires=3600&refresh_token=mock_refresh_token&otherKey={1234}');
|
||||
|
||||
$client = m::mock('Guzzle\Service\Client');
|
||||
$client->shouldReceive('setBaseUrl')->times(1);
|
||||
$client->shouldReceive('post->send')->times(1)->andReturn($response);
|
||||
$client = m::mock('GuzzleHttp\Client');
|
||||
$client->shouldReceive('post')->times(1)->andReturn($response);
|
||||
$this->provider->setHttpClient($client);
|
||||
|
||||
$token = $this->provider->getAccessToken('authorization_code', ['code' => 'mock_authorization_code']);
|
||||
|
@ -94,16 +92,15 @@ class GithubTest extends \PHPUnit_Framework_TestCase
|
|||
|
||||
public function testUserData()
|
||||
{
|
||||
$postResponse = m::mock('Guzzle\Http\Message\Response');
|
||||
$postResponse = m::mock('GuzzleHttp\Message\Response');
|
||||
$postResponse->shouldReceive('getBody')->times(1)->andReturn('access_token=mock_access_token&expires=3600&refresh_token=mock_refresh_token&uid=1');
|
||||
|
||||
$getResponse = m::mock('Guzzle\Http\Message\Response');
|
||||
$getResponse = m::mock('GuzzleHttp\Message\Response');
|
||||
$getResponse->shouldReceive('getBody')->times(4)->andReturn('{"id": 12345, "login": "mock_login", "name": "mock_name", "email": "mock_email"}');
|
||||
|
||||
$client = m::mock('Guzzle\Service\Client');
|
||||
$client->shouldReceive('setBaseUrl')->times(5);
|
||||
$client->shouldReceive('post->send')->times(1)->andReturn($postResponse);
|
||||
$client->shouldReceive('get->send')->times(4)->andReturn($getResponse);
|
||||
$client = m::mock('GuzzleHttp\Client');
|
||||
$client->shouldReceive('post')->times(1)->andReturn($postResponse);
|
||||
$client->shouldReceive('get')->times(4)->andReturn($getResponse);
|
||||
$this->provider->setHttpClient($client);
|
||||
|
||||
$token = $this->provider->getAccessToken('authorization_code', ['code' => 'mock_authorization_code']);
|
||||
|
|
|
@ -50,12 +50,11 @@ class GoogleTest extends \PHPUnit_Framework_TestCase
|
|||
|
||||
public function testGetAccessToken()
|
||||
{
|
||||
$response = m::mock('Guzzle\Http\Message\Response');
|
||||
$response = m::mock('GuzzleHttp\Message\Response');
|
||||
$response->shouldReceive('getBody')->times(1)->andReturn('{"access_token": "mock_access_token", "expires": 3600, "refresh_token": "mock_refresh_token", "uid": 1}');
|
||||
|
||||
$client = m::mock('Guzzle\Service\Client');
|
||||
$client->shouldReceive('setBaseUrl')->times(1);
|
||||
$client->shouldReceive('post->send')->times(1)->andReturn($response);
|
||||
$client = m::mock('GuzzleHttp\Client');
|
||||
$client->shouldReceive('post')->times(1)->andReturn($response);
|
||||
$this->provider->setHttpClient($client);
|
||||
|
||||
$token = $this->provider->getAccessToken('authorization_code', ['code' => 'mock_authorization_code']);
|
||||
|
@ -76,16 +75,15 @@ class GoogleTest extends \PHPUnit_Framework_TestCase
|
|||
|
||||
public function testUserData()
|
||||
{
|
||||
$postResponse = m::mock('Guzzle\Http\Message\Response');
|
||||
$postResponse = m::mock('GuzzleHttp\Message\Response');
|
||||
$postResponse->shouldReceive('getBody')->times(1)->andReturn('{"access_token": "mock_access_token", "expires": 3600, "refresh_token": "mock_refresh_token", "uid": 1}');
|
||||
|
||||
$getResponse = m::mock('Guzzle\Http\Message\Response');
|
||||
$getResponse = m::mock('GuzzleHttp\Message\Response');
|
||||
$getResponse->shouldReceive('getBody')->times(4)->andReturn('{"id": 12345, "name": "mock_name", "given_name": "mock_first_name", "family_name": "mock_last_name", "email": "mock_email"}');
|
||||
|
||||
$client = m::mock('Guzzle\Service\Client');
|
||||
$client->shouldReceive('setBaseUrl')->times(5);
|
||||
$client->shouldReceive('post->send')->times(1)->andReturn($postResponse);
|
||||
$client->shouldReceive('get->send')->times(4)->andReturn($getResponse);
|
||||
$client = m::mock('GuzzleHttp\Client');
|
||||
$client->shouldReceive('post')->times(1)->andReturn($postResponse);
|
||||
$client->shouldReceive('get')->times(4)->andReturn($getResponse);
|
||||
$this->provider->setHttpClient($client);
|
||||
|
||||
$token = $this->provider->getAccessToken('authorization_code', ['code' => 'mock_authorization_code']);
|
||||
|
|
|
@ -48,12 +48,11 @@ class InstagramTest extends \PHPUnit_Framework_TestCase
|
|||
|
||||
public function testGetAccessToken()
|
||||
{
|
||||
$response = m::mock('Guzzle\Http\Message\Response');
|
||||
$response = m::mock('GuzzleHttp\Message\Response');
|
||||
$response->shouldReceive('getBody')->times(1)->andReturn('{"access_token": "mock_access_token", "expires": 3600, "refresh_token": "mock_refresh_token", "uid": 1}');
|
||||
|
||||
$client = m::mock('Guzzle\Service\Client');
|
||||
$client->shouldReceive('setBaseUrl')->times(1);
|
||||
$client->shouldReceive('post->send')->times(1)->andReturn($response);
|
||||
$client = m::mock('GuzzleHttp\Client');
|
||||
$client->shouldReceive('post')->times(1)->andReturn($response);
|
||||
$this->provider->setHttpClient($client);
|
||||
|
||||
$token = $this->provider->getAccessToken('authorization_code', ['code' => 'mock_authorization_code']);
|
||||
|
@ -74,16 +73,15 @@ class InstagramTest extends \PHPUnit_Framework_TestCase
|
|||
|
||||
public function testUserData()
|
||||
{
|
||||
$postResponse = m::mock('Guzzle\Http\Message\Response');
|
||||
$postResponse = m::mock('GuzzleHttp\Message\Response');
|
||||
$postResponse->shouldReceive('getBody')->times(1)->andReturn('{"access_token": "mock_access_token", "expires": 3600, "refresh_token": "mock_refresh_token", "uid": 1}');
|
||||
|
||||
$getResponse = m::mock('Guzzle\Http\Message\Response');
|
||||
$getResponse = m::mock('GuzzleHttp\Message\Response');
|
||||
$getResponse->shouldReceive('getBody')->times(4)->andReturn('{"data": {"id": "12345", "username": "mock_username", "full_name": "mock_full_name", "bio": "mock_bio", "profile_picture": "mock_profile_picture"}}');
|
||||
|
||||
$client = m::mock('Guzzle\Service\Client');
|
||||
$client->shouldReceive('setBaseUrl')->times(5);
|
||||
$client->shouldReceive('post->send')->times(1)->andReturn($postResponse);
|
||||
$client->shouldReceive('get->send')->times(4)->andReturn($getResponse);
|
||||
$client = m::mock('GuzzleHttp\Client');
|
||||
$client->shouldReceive('post')->times(1)->andReturn($postResponse);
|
||||
$client->shouldReceive('get')->times(4)->andReturn($getResponse);
|
||||
$this->provider->setHttpClient($client);
|
||||
|
||||
$token = $this->provider->getAccessToken('authorization_code', ['code' => 'mock_authorization_code']);
|
||||
|
|
|
@ -48,12 +48,11 @@ class LinkedInTest extends \PHPUnit_Framework_TestCase
|
|||
|
||||
public function testGetAccessToken()
|
||||
{
|
||||
$response = m::mock('Guzzle\Http\Message\Response');
|
||||
$response = m::mock('GuzzleHttp\Message\Response');
|
||||
$response->shouldReceive('getBody')->times(1)->andReturn('{"access_token": "mock_access_token", "expires": 3600, "refresh_token": "mock_refresh_token", "uid": 1}');
|
||||
|
||||
$client = m::mock('Guzzle\Service\Client');
|
||||
$client->shouldReceive('setBaseUrl')->times(1);
|
||||
$client->shouldReceive('post->send')->times(1)->andReturn($response);
|
||||
$client = m::mock('GuzzleHttp\Client');
|
||||
$client->shouldReceive('post')->times(1)->andReturn($response);
|
||||
$this->provider->setHttpClient($client);
|
||||
|
||||
$token = $this->provider->getAccessToken('authorization_code', ['code' => 'mock_authorization_code']);
|
||||
|
@ -74,16 +73,15 @@ class LinkedInTest extends \PHPUnit_Framework_TestCase
|
|||
|
||||
public function testUserData()
|
||||
{
|
||||
$postResponse = m::mock('Guzzle\Http\Message\Response');
|
||||
$postResponse = m::mock('GuzzleHttp\Message\Response');
|
||||
$postResponse->shouldReceive('getBody')->times(1)->andReturn('{"access_token": "mock_access_token", "expires": 3600, "refresh_token": "mock_refresh_token", "uid": 1}');
|
||||
|
||||
$getResponse = m::mock('Guzzle\Http\Message\Response');
|
||||
$getResponse = m::mock('GuzzleHttp\Message\Response');
|
||||
$getResponse->shouldReceive('getBody')->times(4)->andReturn('{"id": 12345, "firstName": "mock_first_name", "lastName": "mock_last_name", "emailAddress": "mock_email", "location": { "name": "mock_location" }, "headline": "mock_headline", "pictureUrl": "mock_picture_url", "publicProfileUrl": "mock_profile_url"}');
|
||||
|
||||
$client = m::mock('Guzzle\Service\Client');
|
||||
$client->shouldReceive('setBaseUrl')->times(5);
|
||||
$client->shouldReceive('post->send')->times(1)->andReturn($postResponse);
|
||||
$client->shouldReceive('get->send')->times(4)->andReturn($getResponse);
|
||||
$client = m::mock('GuzzleHttp\Client');
|
||||
$client->shouldReceive('post')->times(1)->andReturn($postResponse);
|
||||
$client->shouldReceive('get')->times(4)->andReturn($getResponse);
|
||||
$this->provider->setHttpClient($client);
|
||||
|
||||
$token = $this->provider->getAccessToken('authorization_code', ['code' => 'mock_authorization_code']);
|
||||
|
|
|
@ -48,12 +48,11 @@ class MicrosoftTest extends \PHPUnit_Framework_TestCase
|
|||
|
||||
public function testGetAccessToken()
|
||||
{
|
||||
$response = m::mock('Guzzle\Http\Message\Response');
|
||||
$response = m::mock('GuzzleHttp\Message\Response');
|
||||
$response->shouldReceive('getBody')->times(1)->andReturn('{"access_token": "mock_access_token", "expires": 3600, "refresh_token": "mock_refresh_token", "uid": 1}');
|
||||
|
||||
$client = m::mock('Guzzle\Service\Client');
|
||||
$client->shouldReceive('setBaseUrl')->times(1);
|
||||
$client->shouldReceive('post->send')->times(1)->andReturn($response);
|
||||
$client = m::mock('GuzzleHttp\Client');
|
||||
$client->shouldReceive('post')->times(1)->andReturn($response);
|
||||
$this->provider->setHttpClient($client);
|
||||
|
||||
$token = $this->provider->getAccessToken('authorization_code', ['code' => 'mock_authorization_code']);
|
||||
|
@ -74,18 +73,18 @@ class MicrosoftTest extends \PHPUnit_Framework_TestCase
|
|||
|
||||
public function testUserData()
|
||||
{
|
||||
$postResponse = m::mock('Guzzle\Http\Message\Response');
|
||||
$postResponse = m::mock('GuzzleHttp\Message\Response');
|
||||
$postResponse->shouldReceive('getBody')->times(1)->andReturn('{"access_token": "mock_access_token", "expires": 3600, "refresh_token": "mock_refresh_token", "uid": 1}');
|
||||
|
||||
$getResponse = m::mock('Guzzle\Http\Message\Response');
|
||||
$getResponse = m::mock('GuzzleHttp\Message\Response');
|
||||
|
||||
$getResponse->shouldReceive('getBody')->times(4)->andReturn('{"id": 12345, "name": "mock_name", "first_name": "mock_first_name", "last_name": "mock_last_name", "emails": {"preferred": "mock_email"}, "link": "mock_link"}');
|
||||
$getResponse->shouldReceive('getInfo')->andReturn(array('url' => 'mock_image_url'));
|
||||
$getResponse->shouldReceive('getInfo')->andReturn(['url' => 'mock_image_url']);
|
||||
|
||||
$client = m::mock('GuzzleHttp\Client');
|
||||
$client->shouldReceive('post')->times(1)->andReturn($postResponse);
|
||||
$client->shouldReceive('get')->times(5)->andReturn($getResponse);
|
||||
|
||||
$client = m::mock('Guzzle\Service\Client');
|
||||
$client->shouldReceive('setBaseUrl')->times(6);
|
||||
$client->shouldReceive('post->send')->times(1)->andReturn($postResponse);
|
||||
$client->shouldReceive('get->send')->times(5)->andReturn($getResponse);
|
||||
$this->provider->setHttpClient($client);
|
||||
|
||||
$token = $this->provider->getAccessToken('authorization_code', ['code' => 'mock_authorization_code']);
|
||||
|
|
|
@ -48,12 +48,11 @@ class VkontakteTest extends \PHPUnit_Framework_TestCase
|
|||
|
||||
public function testGetAccessToken()
|
||||
{
|
||||
$response = m::mock('Guzzle\Http\Message\Response');
|
||||
$response = m::mock('GuzzleHttp\Message\Response');
|
||||
$response->shouldReceive('getBody')->times(1)->andReturn('{"access_token": "mock_access_token", "expires": 3600, "refresh_token": "mock_refresh_token", "uid": 1}');
|
||||
|
||||
$client = m::mock('Guzzle\Service\Client');
|
||||
$client->shouldReceive('setBaseUrl')->times(1);
|
||||
$client->shouldReceive('post->send')->times(1)->andReturn($response);
|
||||
$client = m::mock('GuzzleHttp\Client');
|
||||
$client->shouldReceive('post')->times(1)->andReturn($response);
|
||||
$this->provider->setHttpClient($client);
|
||||
|
||||
$token = $this->provider->getAccessToken('authorization_code', ['code' => 'mock_authorization_code']);
|
||||
|
@ -72,16 +71,15 @@ class VkontakteTest extends \PHPUnit_Framework_TestCase
|
|||
|
||||
public function testUserData()
|
||||
{
|
||||
$postResponse = m::mock('Guzzle\Http\Message\Response');
|
||||
$postResponse = m::mock('GuzzleHttp\Message\Response');
|
||||
$postResponse->shouldReceive('getBody')->times(1)->andReturn('{"access_token": "mock_access_token", "expires": 3600, "refresh_token": "mock_refresh_token", "uid": 1}');
|
||||
|
||||
$getResponse = m::mock('Guzzle\Http\Message\Response');
|
||||
$getResponse = m::mock('GuzzleHttp\Message\Response');
|
||||
$getResponse->shouldReceive('getBody')->times(4)->andReturn('{"response": [{"uid": 12345, "nickname": "mock_nickname", "screen_name": "mock_name", "first_name": "mock_first_name", "last_name": "mock_last_name", "email": "mock_email", "country": "UK", "status": "mock_status", "photo_200_orig": "mock_image_url"}]}');
|
||||
|
||||
$client = m::mock('Guzzle\Service\Client');
|
||||
$client->shouldReceive('setBaseUrl')->times(5);
|
||||
$client->shouldReceive('post->send')->times(1)->andReturn($postResponse);
|
||||
$client->shouldReceive('get->send')->times(4)->andReturn($getResponse);
|
||||
$client = m::mock('GuzzleHttp\Client');
|
||||
$client->shouldReceive('post')->times(1)->andReturn($postResponse);
|
||||
$client->shouldReceive('get')->times(4)->andReturn($getResponse);
|
||||
$this->provider->setHttpClient($client);
|
||||
|
||||
$token = $this->provider->getAccessToken('authorization_code', ['code' => 'mock_authorization_code']);
|
||||
|
|
Loading…
Reference in New Issue