Fixed #90: Authoriztioncode v AuthoriztionCode
parent
424b15d4a8
commit
f559ca1dd5
|
@ -3,7 +3,7 @@
|
|||
"description": "OAuth 2.0 Client Library",
|
||||
"license": "MIT",
|
||||
"require": {
|
||||
"php": ">=5.3.0",
|
||||
"php": ">=5.4.0",
|
||||
"guzzle/guzzle": "~3.7"
|
||||
},
|
||||
"require-dev": {
|
||||
|
@ -36,7 +36,7 @@
|
|||
},
|
||||
"autoload-dev": {
|
||||
"psr-4": {
|
||||
"LeagueTest\\OAuth2\\Client\\": "test/src/"
|
||||
"League\\OAuth2\\Client\\Test\\": "test/src/"
|
||||
}
|
||||
},
|
||||
"extra": {
|
||||
|
|
|
@ -108,7 +108,9 @@ abstract class AbstractProvider
|
|||
public function getAccessToken($grant = 'authorization_code', $params = array())
|
||||
{
|
||||
if (is_string($grant)) {
|
||||
$grant = 'League\\OAuth2\\Client\\Grant\\'.ucfirst(str_replace('_', '', $grant));
|
||||
// PascalCase the grant. E.g: 'authorization_code' becomes 'AuthorizationCode'
|
||||
$className = str_replace(' ', '', ucwords(str_replace(array('-', '_'), ' ', $grant)));
|
||||
$grant = 'League\\OAuth2\\Client\\Grant\\'.$className;
|
||||
if (! class_exists($grant)) {
|
||||
throw new \InvalidArgumentException('Unknown grant "'.$grant.'"');
|
||||
}
|
||||
|
|
|
@ -1,12 +1,13 @@
|
|||
<?php
|
||||
|
||||
namespace LeagueTest\OAuth2\Client\Token;
|
||||
namespace League\OAuth2\Client\Test\Token;
|
||||
|
||||
use League\OAuth2\Client\Entity\User;
|
||||
|
||||
class UserTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
private $user;
|
||||
|
||||
private $userArray;
|
||||
|
||||
public function setUp()
|
||||
|
@ -29,24 +30,24 @@ class UserTest extends \PHPUnit_Framework_TestCase
|
|||
|
||||
public function testExchangeArrayGetArrayCopy()
|
||||
{
|
||||
$this->user->exchangeArray($this->userArray);
|
||||
$this->user->exchangeArray($this->userArray);
|
||||
$this->assertEquals($this->userArray, $this->user->getArrayCopy());
|
||||
}
|
||||
|
||||
public function testMagicMethos()
|
||||
{
|
||||
$this->user->exchangeArray($this->userArray);
|
||||
$this->user->exchangeArray($this->userArray);
|
||||
|
||||
$this->user->name = 'mock_change_test';
|
||||
|
||||
$this->assertTrue(isset($this->user->name));
|
||||
$this->assertTrue(isset($this->user->name));
|
||||
$this->assertEquals('mock_change_test', $this->user->name);
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException PHPUnit_Framework_Error_Notice
|
||||
* Acutal exception expected below but magic testing on phpunit give above
|
||||
* @expectedException \OutOfRangeException
|
||||
* @expectedException \OutOfRangeException
|
||||
*/
|
||||
public function testInvalidMagicSet()
|
||||
{
|
||||
|
@ -54,10 +55,10 @@ class UserTest extends \PHPUnit_Framework_TestCase
|
|||
}
|
||||
|
||||
/**
|
||||
* @expectedException \OutOfRangeException
|
||||
* @expectedException \OutOfRangeException
|
||||
*/
|
||||
public function testInvalidMagicGet()
|
||||
{
|
||||
$mock = $this->user->invalidProp;
|
||||
$this->user->invalidProp;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
<?php
|
||||
|
||||
namespace LeagueTest\OAuth2\Client\Grant;
|
||||
namespace League\OAuth2\Client\Test\Grant;
|
||||
|
||||
use \Mockery as m;
|
||||
|
||||
|
@ -17,11 +17,6 @@ class AuthorizationCodeTest extends \PHPUnit_Framework_TestCase
|
|||
));
|
||||
}
|
||||
|
||||
protected function tearDown()
|
||||
{
|
||||
# m::close();
|
||||
}
|
||||
|
||||
public function testGetAccessToken()
|
||||
{
|
||||
$grant = new \League\OAuth2\Client\Grant\AuthorizationCode();
|
||||
|
@ -41,6 +36,6 @@ class AuthorizationCodeTest extends \PHPUnit_Framework_TestCase
|
|||
$client->shouldReceive('post->send')->times(1)->andReturn($response);
|
||||
$this->provider->setHttpClient($client);
|
||||
|
||||
$token = $this->provider->getAccessToken('authorization_code', array('invalid_code' => 'mock_authorization_code'));
|
||||
$this->provider->getAccessToken('authorization_code', array('invalid_code' => 'mock_authorization_code'));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
<?php
|
||||
|
||||
namespace LeagueTest\OAuth2\Client\Grant;
|
||||
namespace League\OAuth2\Client\Test\Grant;
|
||||
|
||||
use \Mockery as m;
|
||||
|
||||
|
@ -17,11 +17,6 @@ class RefreshTokenTest extends \PHPUnit_Framework_TestCase
|
|||
));
|
||||
}
|
||||
|
||||
protected function tearDown()
|
||||
{
|
||||
# m::close();
|
||||
}
|
||||
|
||||
public function testGetAccessToken()
|
||||
{
|
||||
$response = m::mock('Guzzle\Http\Message\Response');
|
||||
|
@ -33,10 +28,13 @@ class RefreshTokenTest extends \PHPUnit_Framework_TestCase
|
|||
$this->provider->setHttpClient($client);
|
||||
|
||||
$token = $this->provider->getAccessToken('authorization_code', array('code' => 'mock_authorization_code'));
|
||||
$this->assertInstanceOf('League\OAuth2\Client\Token\AccessToken', $token);
|
||||
|
||||
$grant = new \League\OAuth2\Client\Grant\RefreshToken();
|
||||
$refreshToken = $this->provider->getAccessToken($grant, array('refresh_token' => $token->refreshToken));
|
||||
$this->assertEquals('refresh_token', (string) $grant);
|
||||
|
||||
$newToken = $this->provider->getAccessToken($grant, array('refresh_token' => $token->refreshToken));
|
||||
$this->assertInstanceOf('League\OAuth2\Client\Token\AccessToken', $newToken);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
<?php
|
||||
|
||||
namespace LeagueTest\OAuth2\Client\Provider;
|
||||
namespace League\OAuth2\Client\Test\Provider;
|
||||
|
||||
use \Mockery as m;
|
||||
|
||||
class IdentityProviderTest extends \PHPUnit_Framework_TestCase
|
||||
class AbstractProviderTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
protected $provider;
|
||||
|
||||
|
@ -17,17 +17,12 @@ class IdentityProviderTest extends \PHPUnit_Framework_TestCase
|
|||
));
|
||||
}
|
||||
|
||||
protected function tearDown()
|
||||
{
|
||||
# m::close();
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException InvalidArgumentException
|
||||
*/
|
||||
public function testInvalidGrantString()
|
||||
{
|
||||
$test = $this->provider->getAccessToken('invalid_grant', array('invalid_parameter' => 'none'));
|
||||
$this->provider->getAccessToken('invalid_grant', array('invalid_parameter' => 'none'));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -36,6 +31,6 @@ class IdentityProviderTest extends \PHPUnit_Framework_TestCase
|
|||
public function testInvalidGrantObject()
|
||||
{
|
||||
$grant = new \StdClass;
|
||||
$test = $this->provider->getAccessToken($grant, array('invalid_parameter' => 'none'));
|
||||
$this->provider->getAccessToken($grant, array('invalid_parameter' => 'none'));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
<?php
|
||||
|
||||
namespace LeagueTest\OAuth2\Client\Provider;
|
||||
namespace League\OAuth2\Client\Test\Provider;
|
||||
|
||||
use \Mockery as m;
|
||||
|
||||
|
@ -17,11 +17,6 @@ class EventbriteTest extends \PHPUnit_Framework_TestCase
|
|||
));
|
||||
}
|
||||
|
||||
protected function tearDown()
|
||||
{
|
||||
# m::close();
|
||||
}
|
||||
|
||||
public function testAuthorizationUrl()
|
||||
{
|
||||
$url = $this->provider->getAuthorizationUrl();
|
||||
|
@ -56,8 +51,6 @@ class EventbriteTest extends \PHPUnit_Framework_TestCase
|
|||
|
||||
$token = $this->provider->getAccessToken('authorization_code', array('code' => 'mock_authorization_code'));
|
||||
|
||||
# print_r($token);die();
|
||||
|
||||
$this->assertEquals('mock_access_token', $token->accessToken);
|
||||
$this->assertLessThanOrEqual(time() + 3600, $token->expires);
|
||||
$this->assertGreaterThanOrEqual(time(), $token->expires);
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
<?php
|
||||
|
||||
namespace LeagueTest\OAuth2\Client\Provider;
|
||||
namespace League\OAuth2\Client\Test\Provider;
|
||||
|
||||
use \Mockery as m;
|
||||
|
||||
|
@ -17,11 +17,6 @@ class FacebookTest extends \PHPUnit_Framework_TestCase
|
|||
));
|
||||
}
|
||||
|
||||
protected function tearDown()
|
||||
{
|
||||
# m::close();
|
||||
}
|
||||
|
||||
public function testAuthorizationUrl()
|
||||
{
|
||||
$url = $this->provider->getAuthorizationUrl();
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
<?php
|
||||
|
||||
namespace LeagueTest\OAuth2\Client\Provider;
|
||||
namespace League\OAuth2\Client\Test\Provider;
|
||||
|
||||
use \Mockery as m;
|
||||
|
||||
|
@ -17,11 +17,6 @@ class GithubTest extends \PHPUnit_Framework_TestCase
|
|||
));
|
||||
}
|
||||
|
||||
protected function tearDown()
|
||||
{
|
||||
# m::close();
|
||||
}
|
||||
|
||||
public function testAuthorizationUrl()
|
||||
{
|
||||
$url = $this->provider->getAuthorizationUrl();
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
<?php
|
||||
|
||||
namespace LeagueTest\OAuth2\Client\Provider;
|
||||
namespace League\OAuth2\Client\Test\Provider;
|
||||
|
||||
use \Mockery as m;
|
||||
|
||||
|
@ -17,11 +17,6 @@ class GoogleTest extends \PHPUnit_Framework_TestCase
|
|||
));
|
||||
}
|
||||
|
||||
protected function tearDown()
|
||||
{
|
||||
# m::close();
|
||||
}
|
||||
|
||||
public function testAuthorizationUrl()
|
||||
{
|
||||
$url = $this->provider->getAuthorizationUrl();
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
<?php
|
||||
|
||||
namespace LeagueTest\OAuth2\Client\Provider;
|
||||
namespace League\OAuth2\Client\Test\Provider;
|
||||
|
||||
use \Mockery as m;
|
||||
|
||||
|
@ -17,11 +17,6 @@ class InstagramTest extends \PHPUnit_Framework_TestCase
|
|||
));
|
||||
}
|
||||
|
||||
protected function tearDown()
|
||||
{
|
||||
# m::close();
|
||||
}
|
||||
|
||||
public function testAuthorizationUrl()
|
||||
{
|
||||
$url = $this->provider->getAuthorizationUrl();
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
<?php
|
||||
|
||||
namespace LeagueTest\OAuth2\Client\Provider;
|
||||
namespace League\OAuth2\Client\Test\Provider;
|
||||
|
||||
use \Mockery as m;
|
||||
|
||||
|
@ -17,11 +17,6 @@ class LinkedInTest extends \PHPUnit_Framework_TestCase
|
|||
));
|
||||
}
|
||||
|
||||
protected function tearDown()
|
||||
{
|
||||
# m::close();
|
||||
}
|
||||
|
||||
public function testAuthorizationUrl()
|
||||
{
|
||||
$url = $this->provider->getAuthorizationUrl();
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
<?php
|
||||
|
||||
namespace LeagueTest\OAuth2\Client\Provider;
|
||||
namespace League\OAuth2\Client\Test\Provider;
|
||||
|
||||
use \Mockery as m;
|
||||
|
||||
|
@ -17,11 +17,6 @@ class MicrosoftTest extends \PHPUnit_Framework_TestCase
|
|||
));
|
||||
}
|
||||
|
||||
protected function tearDown()
|
||||
{
|
||||
# m::close();
|
||||
}
|
||||
|
||||
public function testAuthorizationUrl()
|
||||
{
|
||||
$url = $this->provider->getAuthorizationUrl();
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
<?php
|
||||
|
||||
namespace LeagueTest\OAuth2\Client\Provider;
|
||||
namespace League\OAuth2\Client\Test\Provider;
|
||||
|
||||
use \Mockery as m;
|
||||
|
||||
|
@ -17,11 +17,6 @@ class VkontakteTest extends \PHPUnit_Framework_TestCase
|
|||
));
|
||||
}
|
||||
|
||||
protected function tearDown()
|
||||
{
|
||||
# m::close();
|
||||
}
|
||||
|
||||
public function testAuthorizationUrl()
|
||||
{
|
||||
$url = $this->provider->getAuthorizationUrl();
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
<?php
|
||||
|
||||
namespace LeagueTest\OAuth2\Client\Token;
|
||||
namespace League\OAuth2\Client\Test\Token;
|
||||
|
||||
class AccessTokenTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
|
@ -9,6 +9,6 @@ class AccessTokenTest extends \PHPUnit_Framework_TestCase
|
|||
*/
|
||||
public function testInvalidRefreshToken()
|
||||
{
|
||||
$test = new \League\OAuth2\Client\Token\AccessToken(array('invalid_access_token' => 'none'));
|
||||
new \League\OAuth2\Client\Token\AccessToken(array('invalid_access_token' => 'none'));
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue