commit
c8ce5f357b
|
@ -2,7 +2,7 @@
|
|||
|
||||
namespace League\OAuth2\Client\Test\Grant;
|
||||
|
||||
use \Mockery as m;
|
||||
use Mockery as m;
|
||||
|
||||
class AuthorizationCodeTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
|
@ -17,6 +17,12 @@ class AuthorizationCodeTest extends \PHPUnit_Framework_TestCase
|
|||
]);
|
||||
}
|
||||
|
||||
public function tearDown()
|
||||
{
|
||||
m::close();
|
||||
parent::tearDown();
|
||||
}
|
||||
|
||||
public function testGetAccessToken()
|
||||
{
|
||||
$grant = new \League\OAuth2\Client\Grant\AuthorizationCode();
|
||||
|
@ -28,14 +34,6 @@ class AuthorizationCodeTest extends \PHPUnit_Framework_TestCase
|
|||
*/
|
||||
public function testInvalidRefreshToken()
|
||||
{
|
||||
$response = m::mock('Guzzle\Http\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(1);
|
||||
$client->shouldReceive('post->send')->times(1)->andReturn($response);
|
||||
$this->provider->setHttpClient($client);
|
||||
|
||||
$this->provider->getAccessToken('authorization_code', ['invalid_code' => 'mock_authorization_code']);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
namespace League\OAuth2\Client\Test\Grant;
|
||||
|
||||
use \Mockery as m;
|
||||
use Mockery as m;
|
||||
|
||||
class ClientCredentialsTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
|
@ -17,10 +17,16 @@ class ClientCredentialsTest extends \PHPUnit_Framework_TestCase
|
|||
));
|
||||
}
|
||||
|
||||
public function tearDown()
|
||||
{
|
||||
m::close();
|
||||
parent::tearDown();
|
||||
}
|
||||
|
||||
public function testGetAccessToken()
|
||||
{
|
||||
$response = m::mock('Guzzle\Http\Message\Response');
|
||||
$response->shouldReceive('getBody')->times(2)->andReturn('{"access_token": "mock_access_token", "expires": 3600, "refresh_token": "mock_refresh_token", "uid": 1}');
|
||||
$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);
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
namespace League\OAuth2\Client\Test\Grant;
|
||||
|
||||
use \Mockery as m;
|
||||
use Mockery as m;
|
||||
|
||||
class PasswordTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
|
@ -17,10 +17,16 @@ class PasswordTest extends \PHPUnit_Framework_TestCase
|
|||
));
|
||||
}
|
||||
|
||||
public function tearDown()
|
||||
{
|
||||
m::close();
|
||||
parent::tearDown();
|
||||
}
|
||||
|
||||
public function testGetAccessToken()
|
||||
{
|
||||
$response = m::mock('Guzzle\Http\Message\Response');
|
||||
$response->shouldReceive('getBody')->times(2)->andReturn('{"access_token": "mock_access_token", "expires": 3600, "refresh_token": "mock_refresh_token", "uid": 1}');
|
||||
$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);
|
||||
|
@ -39,14 +45,6 @@ class PasswordTest extends \PHPUnit_Framework_TestCase
|
|||
*/
|
||||
public function testInvalidUsername()
|
||||
{
|
||||
$response = m::mock('Guzzle\Http\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(1);
|
||||
$client->shouldReceive('post->send')->times(1)->andReturn($response);
|
||||
$this->provider->setHttpClient($client);
|
||||
|
||||
$this->provider->getAccessToken('password', array('invalid_username' => 'mock_username', 'password' => 'mock_password'));
|
||||
}
|
||||
|
||||
|
@ -55,14 +53,6 @@ class PasswordTest extends \PHPUnit_Framework_TestCase
|
|||
*/
|
||||
public function testInvalidPassword()
|
||||
{
|
||||
$response = m::mock('Guzzle\Http\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(1);
|
||||
$client->shouldReceive('post->send')->times(1)->andReturn($response);
|
||||
$this->provider->setHttpClient($client);
|
||||
|
||||
$this->provider->getAccessToken('password', array('username' => 'mock_username', 'invalid_password' => 'mock_password'));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
namespace League\OAuth2\Client\Test\Grant;
|
||||
|
||||
use \Mockery as m;
|
||||
use Mockery as m;
|
||||
|
||||
class RefreshTokenTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
|
@ -17,14 +17,20 @@ class RefreshTokenTest extends \PHPUnit_Framework_TestCase
|
|||
]);
|
||||
}
|
||||
|
||||
public function tearDown()
|
||||
{
|
||||
m::close();
|
||||
parent::tearDown();
|
||||
}
|
||||
|
||||
public function testGetAccessToken()
|
||||
{
|
||||
$response = m::mock('Guzzle\Http\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(1);
|
||||
$client->shouldReceive('post->send')->times(1)->andReturn($response);
|
||||
$client->shouldReceive('setBaseUrl')->times(2);
|
||||
$client->shouldReceive('post->send')->times(2)->andReturn($response);
|
||||
$this->provider->setHttpClient($client);
|
||||
|
||||
$token = $this->provider->getAccessToken('authorization_code', ['code' => 'mock_authorization_code']);
|
||||
|
@ -43,7 +49,7 @@ class RefreshTokenTest extends \PHPUnit_Framework_TestCase
|
|||
public function testInvalidRefreshToken()
|
||||
{
|
||||
$response = m::mock('Guzzle\Http\Message\Response');
|
||||
$response->shouldReceive('getBody')->times(2)->andReturn('{"access_token": "mock_access_token", "expires": 3600, "refresh_token": "mock_refresh_token", "uid": 1}');
|
||||
$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);
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
namespace League\OAuth2\Client\Test\Provider;
|
||||
|
||||
use Mockery as m;
|
||||
|
||||
class AbstractProviderTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
|
@ -16,6 +17,12 @@ class AbstractProviderTest extends \PHPUnit_Framework_TestCase
|
|||
]);
|
||||
}
|
||||
|
||||
public function tearDown()
|
||||
{
|
||||
m::close();
|
||||
parent::tearDown();
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException InvalidArgumentException
|
||||
*/
|
||||
|
@ -32,14 +39,14 @@ class AbstractProviderTest extends \PHPUnit_Framework_TestCase
|
|||
$grant = new \StdClass();
|
||||
$this->provider->getAccessToken($grant, ['invalid_parameter' => 'none']);
|
||||
}
|
||||
|
||||
|
||||
public function testAuthorizationUrlStateParam()
|
||||
{
|
||||
$this->assertContains('state=XXX', $this->provider->getAuthorizationUrl([
|
||||
'state' => 'XXX'
|
||||
]));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Tests https://github.com/thephpleague/oauth2-client/issues/134
|
||||
*/
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
namespace League\OAuth2\Client\Test\Provider;
|
||||
|
||||
use \Mockery as m;
|
||||
use Mockery as m;
|
||||
|
||||
class EventbriteTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
|
@ -17,6 +17,12 @@ class EventbriteTest extends \PHPUnit_Framework_TestCase
|
|||
]);
|
||||
}
|
||||
|
||||
public function tearDown()
|
||||
{
|
||||
m::close();
|
||||
parent::tearDown();
|
||||
}
|
||||
|
||||
public function testAuthorizationUrl()
|
||||
{
|
||||
$url = $this->provider->getAuthorizationUrl();
|
||||
|
@ -70,13 +76,13 @@ class EventbriteTest extends \PHPUnit_Framework_TestCase
|
|||
$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->shouldReceive('getBody')->times(1)->andReturn('{"user": {"user_id": 12345, "email": "mock_email"}}');
|
||||
$getResponse->shouldReceive('getBody')->times(4)->andReturn('{"user": {"user_id": 12345, "email": "mock_email"}}');
|
||||
|
||||
$client = m::mock('Guzzle\Service\Client');
|
||||
$client->shouldReceive('setBaseUrl')->times(1);
|
||||
$client->shouldReceive('setBaseUrl')->times(5);
|
||||
$client->shouldReceive('post->send')->times(1)->andReturn($postResponse);
|
||||
$client->shouldReceive('get->send')->times(1)->andReturn($getResponse);
|
||||
$client->shouldReceive('setDefaultOption')->times(1);
|
||||
$client->shouldReceive('get->send')->times(4)->andReturn($getResponse);
|
||||
$client->shouldReceive('setDefaultOption')->times(4);
|
||||
$this->provider->setHttpClient($client);
|
||||
|
||||
$token = $this->provider->getAccessToken('authorization_code', ['code' => 'mock_authorization_code']);
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
namespace League\OAuth2\Client\Test\Provider;
|
||||
|
||||
use \Mockery as m;
|
||||
use Mockery as m;
|
||||
|
||||
class FacebookTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
|
@ -17,6 +17,12 @@ class FacebookTest extends \PHPUnit_Framework_TestCase
|
|||
]);
|
||||
}
|
||||
|
||||
public function tearDown()
|
||||
{
|
||||
m::close();
|
||||
parent::tearDown();
|
||||
}
|
||||
|
||||
public function testAuthorizationUrl()
|
||||
{
|
||||
$url = $this->provider->getAuthorizationUrl();
|
||||
|
@ -76,7 +82,7 @@ class FacebookTest extends \PHPUnit_Framework_TestCase
|
|||
$getResponse->shouldReceive('getInfo')->andReturn(['url' => 'mock_image_url']);
|
||||
|
||||
$client = m::mock('Guzzle\Service\Client');
|
||||
$client->shouldReceive('setBaseUrl')->times(1);
|
||||
$client->shouldReceive('setBaseUrl')->times(6);
|
||||
$client->shouldReceive('post->send')->times(1)->andReturn($postResponse);
|
||||
$client->shouldReceive('get->send')->andReturn($getResponse);
|
||||
$this->provider->setHttpClient($client);
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
namespace League\OAuth2\Client\Test\Provider;
|
||||
|
||||
use \Mockery as m;
|
||||
use Mockery as m;
|
||||
|
||||
class GithubTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
|
@ -17,6 +17,12 @@ class GithubTest extends \PHPUnit_Framework_TestCase
|
|||
]);
|
||||
}
|
||||
|
||||
public function tearDown()
|
||||
{
|
||||
m::close();
|
||||
parent::tearDown();
|
||||
}
|
||||
|
||||
public function testAuthorizationUrl()
|
||||
{
|
||||
$url = $this->provider->getAuthorizationUrl();
|
||||
|
@ -92,12 +98,12 @@ class GithubTest extends \PHPUnit_Framework_TestCase
|
|||
$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->shouldReceive('getBody')->times(1)->andReturn('{"id": 12345, "login": "mock_login", "name": "mock_name", "email": "mock_email"}');
|
||||
$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(1);
|
||||
$client->shouldReceive('setBaseUrl')->times(5);
|
||||
$client->shouldReceive('post->send')->times(1)->andReturn($postResponse);
|
||||
$client->shouldReceive('get->send')->times(1)->andReturn($getResponse);
|
||||
$client->shouldReceive('get->send')->times(4)->andReturn($getResponse);
|
||||
$this->provider->setHttpClient($client);
|
||||
|
||||
$token = $this->provider->getAccessToken('authorization_code', ['code' => 'mock_authorization_code']);
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
namespace League\OAuth2\Client\Test\Provider;
|
||||
|
||||
use \Mockery as m;
|
||||
use Mockery as m;
|
||||
|
||||
class GoogleTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
|
@ -18,6 +18,12 @@ class GoogleTest extends \PHPUnit_Framework_TestCase
|
|||
]);
|
||||
}
|
||||
|
||||
public function tearDown()
|
||||
{
|
||||
m::close();
|
||||
parent::tearDown();
|
||||
}
|
||||
|
||||
public function testAuthorizationUrl()
|
||||
{
|
||||
$url = $this->provider->getAuthorizationUrl();
|
||||
|
@ -74,12 +80,12 @@ class GoogleTest extends \PHPUnit_Framework_TestCase
|
|||
$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->shouldReceive('getBody')->times(1)->andReturn('{"id": 12345, "name": "mock_name", "given_name": "mock_first_name", "family_name": "mock_last_name", "email": "mock_email"}');
|
||||
$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(1);
|
||||
$client->shouldReceive('setBaseUrl')->times(5);
|
||||
$client->shouldReceive('post->send')->times(1)->andReturn($postResponse);
|
||||
$client->shouldReceive('get->send')->times(1)->andReturn($getResponse);
|
||||
$client->shouldReceive('get->send')->times(4)->andReturn($getResponse);
|
||||
$this->provider->setHttpClient($client);
|
||||
|
||||
$token = $this->provider->getAccessToken('authorization_code', ['code' => 'mock_authorization_code']);
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
namespace League\OAuth2\Client\Test\Provider;
|
||||
|
||||
use \Mockery as m;
|
||||
use Mockery as m;
|
||||
|
||||
class InstagramTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
|
@ -17,6 +17,12 @@ class InstagramTest extends \PHPUnit_Framework_TestCase
|
|||
]);
|
||||
}
|
||||
|
||||
public function tearDown()
|
||||
{
|
||||
m::close();
|
||||
parent::tearDown();
|
||||
}
|
||||
|
||||
public function testAuthorizationUrl()
|
||||
{
|
||||
$url = $this->provider->getAuthorizationUrl();
|
||||
|
@ -72,12 +78,12 @@ class InstagramTest extends \PHPUnit_Framework_TestCase
|
|||
$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->shouldReceive('getBody')->times(1)->andReturn('{"data": {"id": "12345", "username": "mock_username", "full_name": "mock_full_name", "bio": "mock_bio", "profile_picture": "mock_profile_picture"}}');
|
||||
$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(1);
|
||||
$client->shouldReceive('setBaseUrl')->times(5);
|
||||
$client->shouldReceive('post->send')->times(1)->andReturn($postResponse);
|
||||
$client->shouldReceive('get->send')->times(1)->andReturn($getResponse);
|
||||
$client->shouldReceive('get->send')->times(4)->andReturn($getResponse);
|
||||
$this->provider->setHttpClient($client);
|
||||
|
||||
$token = $this->provider->getAccessToken('authorization_code', ['code' => 'mock_authorization_code']);
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
namespace League\OAuth2\Client\Test\Provider;
|
||||
|
||||
use \Mockery as m;
|
||||
use Mockery as m;
|
||||
|
||||
class LinkedInTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
|
@ -17,6 +17,12 @@ class LinkedInTest extends \PHPUnit_Framework_TestCase
|
|||
]);
|
||||
}
|
||||
|
||||
public function tearDown()
|
||||
{
|
||||
m::close();
|
||||
parent::tearDown();
|
||||
}
|
||||
|
||||
public function testAuthorizationUrl()
|
||||
{
|
||||
$url = $this->provider->getAuthorizationUrl();
|
||||
|
@ -72,12 +78,12 @@ class LinkedInTest extends \PHPUnit_Framework_TestCase
|
|||
$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->shouldReceive('getBody')->times(1)->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"}');
|
||||
$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(1);
|
||||
$client->shouldReceive('setBaseUrl')->times(5);
|
||||
$client->shouldReceive('post->send')->times(1)->andReturn($postResponse);
|
||||
$client->shouldReceive('get->send')->times(1)->andReturn($getResponse);
|
||||
$client->shouldReceive('get->send')->times(4)->andReturn($getResponse);
|
||||
$this->provider->setHttpClient($client);
|
||||
|
||||
$token = $this->provider->getAccessToken('authorization_code', ['code' => 'mock_authorization_code']);
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
namespace League\OAuth2\Client\Test\Provider;
|
||||
|
||||
use \Mockery as m;
|
||||
use Mockery as m;
|
||||
|
||||
class MicrosoftTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
|
@ -17,6 +17,12 @@ class MicrosoftTest extends \PHPUnit_Framework_TestCase
|
|||
]);
|
||||
}
|
||||
|
||||
public function tearDown()
|
||||
{
|
||||
m::close();
|
||||
parent::tearDown();
|
||||
}
|
||||
|
||||
public function testAuthorizationUrl()
|
||||
{
|
||||
$url = $this->provider->getAuthorizationUrl();
|
||||
|
@ -72,13 +78,14 @@ class MicrosoftTest extends \PHPUnit_Framework_TestCase
|
|||
$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->shouldReceive('getBody')->times(1)->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(['url' => 'mock_image_url']);
|
||||
|
||||
$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'));
|
||||
|
||||
$client = m::mock('Guzzle\Service\Client');
|
||||
$client->shouldReceive('setBaseUrl')->times(1);
|
||||
$client->shouldReceive('setBaseUrl')->times(6);
|
||||
$client->shouldReceive('post->send')->times(1)->andReturn($postResponse);
|
||||
$client->shouldReceive('get->send')->times(1)->andReturn($getResponse);
|
||||
$client->shouldReceive('get->send')->times(5)->andReturn($getResponse);
|
||||
$this->provider->setHttpClient($client);
|
||||
|
||||
$token = $this->provider->getAccessToken('authorization_code', ['code' => 'mock_authorization_code']);
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
namespace League\OAuth2\Client\Test\Provider;
|
||||
|
||||
use \Mockery as m;
|
||||
use Mockery as m;
|
||||
|
||||
class VkontakteTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
|
@ -17,6 +17,12 @@ class VkontakteTest extends \PHPUnit_Framework_TestCase
|
|||
]);
|
||||
}
|
||||
|
||||
public function tearDown()
|
||||
{
|
||||
m::close();
|
||||
parent::tearDown();
|
||||
}
|
||||
|
||||
public function testAuthorizationUrl()
|
||||
{
|
||||
$url = $this->provider->getAuthorizationUrl();
|
||||
|
@ -70,12 +76,12 @@ class VkontakteTest extends \PHPUnit_Framework_TestCase
|
|||
$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->shouldReceive('getBody')->times(1)->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"}]}');
|
||||
$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(1);
|
||||
$client->shouldReceive('setBaseUrl')->times(5);
|
||||
$client->shouldReceive('post->send')->times(1)->andReturn($postResponse);
|
||||
$client->shouldReceive('get->send')->times(1)->andReturn($getResponse);
|
||||
$client->shouldReceive('get->send')->times(4)->andReturn($getResponse);
|
||||
$this->provider->setHttpClient($client);
|
||||
|
||||
$token = $this->provider->getAccessToken('authorization_code', ['code' => 'mock_authorization_code']);
|
||||
|
|
|
@ -14,7 +14,7 @@ class AccessTokenTest extends \PHPUnit_Framework_TestCase
|
|||
|
||||
public function testExpiresInCorrection()
|
||||
{
|
||||
$options =array('access_token' => 'access_token', 'expires_in' => 100);
|
||||
$options = array('access_token' => 'access_token', 'expires_in' => 100);
|
||||
$token = new \League\OAuth2\Client\Token\AccessToken($options);
|
||||
$this->assertNotNull($token->expires);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue