diff --git a/README.md b/README.md index ff47bfce..06e193a5 100644 --- a/README.md +++ b/README.md @@ -9,7 +9,7 @@ The framework is provided as a Composer package which can be installed by adding ```javascript { "require": { - "lncd\Oauth2": "*" + "lncd\OAuth2": "*" } } ``` diff --git a/src/OAuth2/Authentication/Server.php b/src/OAuth2/Authentication/Server.php index 259d0ffb..755ca976 100644 --- a/src/OAuth2/Authentication/Server.php +++ b/src/OAuth2/Authentication/Server.php @@ -639,7 +639,7 @@ class Server $userId = call_user_func($this->_grantTypeCallbacks['password'], $params['username'], $params['password']); if ($userId === false) { - throw new \Oauth2\Authentication\ClientException($this->errors['invalid_credentials'], 0); + throw new \OAuth2\Authentication\ClientException($this->errors['invalid_credentials'], 0); } // Generate an access token @@ -730,7 +730,7 @@ class Server $sessionId = $this->_dbCall('validateRefreshToken', $params['refresh_token'], $params['client_id']); if ($sessionId === false) { - throw new \Oauth2\Authentication\ClientException($this->errors['invalid_refresh'], 0); + throw new \OAuth2\Authentication\ClientException($this->errors['invalid_refresh'], 0); } // Generate new tokens @@ -778,7 +778,7 @@ class Server } if ( ! $this->_db instanceof Database) { - throw new ServerException('Registered database abstractor is not an instance of Oauth2\Authentication\Database'); + throw new ServerException('Registered database abstractor is not an instance of OAuth2\Authentication\Database'); } $args = func_get_args(); diff --git a/src/OAuth2/Client/IDP.php b/src/OAuth2/Client/IDP.php index 2dbe182b..092da0e6 100644 --- a/src/OAuth2/Client/IDP.php +++ b/src/OAuth2/Client/IDP.php @@ -100,9 +100,9 @@ abstract class IDP { abstract public function urlAccessToken(); - abstract public function urlUserDetails(\Oauth2\Client\Token\Access $token); + abstract public function urlUserDetails(\OAuth2\Client\Token\Access $token); - abstract public function userDetails($response, \Oauth2\Client\Token\Access $token); + abstract public function userDetails($response, \OAuth2\Client\Token\Access $token); public function authorize($options = array()) { @@ -191,24 +191,24 @@ abstract class IDP { if (isset($result['error']) && ! empty($result['error'])) { - throw new \Oauth2\Client\IDPException($result); + throw new \OAuth2\Client\IDPException($result); } switch ($params['grant_type']) { case 'authorization_code': - return \Oauth2\Client\Token::factory('access', $result); + return \OAuth2\Client\Token::factory('access', $result); break; case 'refresh_token': - return \Oauth2\Client\Token::factory('refresh', $result); + return \OAuth2\Client\Token::factory('refresh', $result); break; } } - public function getUserDetails(\Oauth2\Client\Token\Access $token) + public function getUserDetails(\OAuth2\Client\Token\Access $token) { $url = $this->urlUserDetails($token); @@ -223,7 +223,7 @@ abstract class IDP { catch (\Guzzle\Http\Exception\BadResponseException $e) { $raw_response = explode("\n", $e->getResponse()); - throw new \Oauth2\Client\IDPException(end($raw_response)); + throw new \OAuth2\Client\IDPException(end($raw_response)); } } diff --git a/src/OAuth2/Client/Provider/Blooie.php b/src/OAuth2/Client/Provider/Blooie.php index 8078690e..9ae7dc45 100755 --- a/src/OAuth2/Client/Provider/Blooie.php +++ b/src/OAuth2/Client/Provider/Blooie.php @@ -1,14 +1,14 @@ $token->access_token, diff --git a/src/OAuth2/Client/Provider/Facebook.php b/src/OAuth2/Client/Provider/Facebook.php index 53aba543..cd41be17 100755 --- a/src/OAuth2/Client/Provider/Facebook.php +++ b/src/OAuth2/Client/Provider/Facebook.php @@ -9,7 +9,7 @@ * @license http://philsturgeon.co.uk/code/dbad-license */ -class Facebook extends Oauth2\Client\IDP +class Facebook extends OAuth2\Client\IDP { protected $scope = array('offline_access', 'email', 'read_stream'); @@ -23,7 +23,7 @@ class Facebook extends Oauth2\Client\IDP return 'https://graph.facebook.com/oauth/access_token'; } - public function getUserInfo(Oauth2\Token\Access $token) + public function getUserInfo(OAuth2\Token\Access $token) { $url = 'https://graph.facebook.com/me?'.http_build_query(array( 'access_token' => $token->access_token, diff --git a/src/OAuth2/Client/Provider/Foursquare.php b/src/OAuth2/Client/Provider/Foursquare.php index ebf81cb1..1c2740f8 100755 --- a/src/OAuth2/Client/Provider/Foursquare.php +++ b/src/OAuth2/Client/Provider/Foursquare.php @@ -9,8 +9,8 @@ * @license http://philsturgeon.co.uk/code/dbad-license */ -class Foursquare extends Oauth2\Client\IDP -{ +class Foursquare extends OAuth2\Client\IDP +{ public $method = 'POST'; public function urlAuthorize() @@ -23,7 +23,7 @@ class Foursquare extends Oauth2\Client\IDP return 'https://foursquare.com/oauth2/access_token'; } - public function getUserInfo(Oauth2\Token\Access $token) + public function getUserInfo(OAuth2\Token\Access $token) { $url = 'https://api.foursquare.com/v2/users/self?'.http_build_query(array( 'oauth_token' => $token->access_token, diff --git a/src/OAuth2/Client/Provider/Github.php b/src/OAuth2/Client/Provider/Github.php index acfd59ff..5ca9b512 100755 --- a/src/OAuth2/Client/Provider/Github.php +++ b/src/OAuth2/Client/Provider/Github.php @@ -9,7 +9,7 @@ * @license http://philsturgeon.co.uk/code/dbad-license */ -class OAuth2_Provider_Github extends Oauth2\Client\IDP +class OAuth2_Provider_Github extends OAuth2\Client\IDP { public function urlAuthorize() { diff --git a/src/OAuth2/Client/Token.php b/src/OAuth2/Client/Token.php index 2cb15b12..e4bae4bc 100755 --- a/src/OAuth2/Client/Token.php +++ b/src/OAuth2/Client/Token.php @@ -1,6 +1,6 @@ oauth = new Oauth2\Authentication\Server(); + $this->oauth = new OAuth2\Authentication\Server(); require_once 'database_mock.php'; $this->oauthdb = new OAuthdb(); - $this->assertInstanceOf('Oauth2\Authentication\Database', $this->oauthdb); + $this->assertInstanceOf('OAuth2\Authentication\Database', $this->oauthdb); $this->oauth->registerDbAbstractor($this->oauthdb); } public function test_setupWithOptions() { - $o = new Oauth2\Authentication\Server(array( + $o = new OAuth2\Authentication\Server(array( 'access_token_ttl' => 86400 )); @@ -116,7 +116,7 @@ class Authentication_Server_test extends PHPUnit_Framework_TestCase } /** - * @expectedException Oauth2\Authentication\ClientException + * @expectedException OAuth2\Authentication\ClientException * @expectedExceptionCode 0 */ public function test_checkClientAuthoriseParams_missingClientId() @@ -125,7 +125,7 @@ class Authentication_Server_test extends PHPUnit_Framework_TestCase } /** - * @expectedException Oauth2\Authentication\ClientException + * @expectedException OAuth2\Authentication\ClientException * @expectedExceptionCode 0 */ public function test_checkClientAuthoriseParams_missingRedirectUri() @@ -136,7 +136,7 @@ class Authentication_Server_test extends PHPUnit_Framework_TestCase } /** - * @expectedException Oauth2\Authentication\ClientException + * @expectedException OAuth2\Authentication\ClientException * @expectedExceptionCode 0 */ public function test_checkClientAuthoriseParams_missingResponseType() @@ -148,7 +148,7 @@ class Authentication_Server_test extends PHPUnit_Framework_TestCase } /** - * @expectedException Oauth2\Authentication\ClientException + * @expectedException OAuth2\Authentication\ClientException * @expectedExceptionCode 0 */ public function test_checkClientAuthoriseParams_missingScopes() @@ -162,7 +162,7 @@ class Authentication_Server_test extends PHPUnit_Framework_TestCase } /** - * @expectedException Oauth2\Authentication\ClientException + * @expectedException OAuth2\Authentication\ClientException * @expectedExceptionCode 4 */ public function test_checkClientAuthoriseParams_invalidScopes() @@ -176,7 +176,7 @@ class Authentication_Server_test extends PHPUnit_Framework_TestCase } /** - * @expectedException Oauth2\Authentication\ClientException + * @expectedException OAuth2\Authentication\ClientException * @expectedExceptionCode 8 */ public function test_checkClientAuthoriseParams_invalidClient() @@ -190,7 +190,7 @@ class Authentication_Server_test extends PHPUnit_Framework_TestCase } /** - * @expectedException Oauth2\Authentication\ClientException + * @expectedException OAuth2\Authentication\ClientException * @expectedExceptionCode 3 */ public function test_checkClientAuthoriseParams_invalidResponseType() @@ -247,7 +247,7 @@ class Authentication_Server_test extends PHPUnit_Framework_TestCase } /** - * @expectedException Oauth2\Authentication\ClientException + * @expectedException OAuth2\Authentication\ClientException * @expectedExceptionCode 7 */ public function test_issueAccessTokenNoRegisteredGrant() @@ -537,7 +537,7 @@ class Authentication_Server_test extends PHPUnit_Framework_TestCase } /** - * @expectedException Oauth2\Authentication\ClientException + * @expectedException OAuth2\Authentication\ClientException * @expectedExceptionCode 0 */ public function test_issueAccessToken_refresh_tokenMissingToken() @@ -584,7 +584,7 @@ class Authentication_Server_test extends PHPUnit_Framework_TestCase } /** - * @expectedException Oauth2\Authentication\ClientException + * @expectedException OAuth2\Authentication\ClientException * @expectedExceptionCode 0 */ public function test_issueAccessToken_invalid_refresh_token() @@ -632,7 +632,7 @@ class Authentication_Server_test extends PHPUnit_Framework_TestCase } /** - * @expectedException Oauth2\Authentication\ServerException + * @expectedException OAuth2\Authentication\ServerException * @expectedExceptionCode 0 */ public function test_issueAccessToken_password_grant_Missing_Callback() @@ -707,7 +707,7 @@ class Authentication_Server_test extends PHPUnit_Framework_TestCase } /** - * @expectedException Oauth2\Authentication\ClientException + * @expectedException OAuth2\Authentication\ClientException * @expectedExceptionCode 0 */ public function test_issueAccessToken_password_grant_wrongCreds() @@ -726,7 +726,7 @@ class Authentication_Server_test extends PHPUnit_Framework_TestCase } /** - * @expectedException Oauth2\Authentication\ClientException + * @expectedException OAuth2\Authentication\ClientException * @expectedExceptionCode 0 */ public function test_issueAccessToken_password_grant_missingUsername() @@ -743,7 +743,7 @@ class Authentication_Server_test extends PHPUnit_Framework_TestCase } /** - * @expectedException Oauth2\Authentication\ClientException + * @expectedException OAuth2\Authentication\ClientException * @expectedExceptionCode 0 */ public function test_issueAccessToken_password_grant_missingPassword() @@ -761,7 +761,7 @@ class Authentication_Server_test extends PHPUnit_Framework_TestCase } /** - * @expectedException Oauth2\Authentication\ClientException + * @expectedException OAuth2\Authentication\ClientException * @expectedExceptionCode 0 */ public function test_issueAccessToken_missingGrantType() @@ -770,7 +770,7 @@ class Authentication_Server_test extends PHPUnit_Framework_TestCase } /** - * @expectedException Oauth2\Authentication\ClientException + * @expectedException OAuth2\Authentication\ClientException * @expectedExceptionCode 7 */ public function test_issueAccessToken_unsupportedGrantType() @@ -781,7 +781,7 @@ class Authentication_Server_test extends PHPUnit_Framework_TestCase } /** - * @expectedException Oauth2\Authentication\ClientException + * @expectedException OAuth2\Authentication\ClientException * @expectedExceptionCode 0 */ public function test_completeAuthCodeGrant_missingClientId() @@ -794,7 +794,7 @@ class Authentication_Server_test extends PHPUnit_Framework_TestCase } /** - * @expectedException Oauth2\Authentication\ClientException + * @expectedException OAuth2\Authentication\ClientException * @expectedExceptionCode 0 */ public function test_completeAuthCodeGrant_missingClientSecret() @@ -809,7 +809,7 @@ class Authentication_Server_test extends PHPUnit_Framework_TestCase } /** - * @expectedException Oauth2\Authentication\ClientException + * @expectedException OAuth2\Authentication\ClientException * @expectedExceptionCode 0 */ public function test_completeAuthCodeGrant_missingRedirectUri() @@ -825,7 +825,7 @@ class Authentication_Server_test extends PHPUnit_Framework_TestCase } /** - * @expectedException Oauth2\Authentication\ClientException + * @expectedException OAuth2\Authentication\ClientException * @expectedExceptionCode 8 */ public function test_completeAuthCodeGrant_invalidClient() @@ -842,7 +842,7 @@ class Authentication_Server_test extends PHPUnit_Framework_TestCase } /** - * @expectedException Oauth2\Authentication\ClientException + * @expectedException OAuth2\Authentication\ClientException * @expectedExceptionCode 0 */ public function test_completeAuthCodeGrant_missingCode() @@ -859,7 +859,7 @@ class Authentication_Server_test extends PHPUnit_Framework_TestCase } /** - * @expectedException Oauth2\Authentication\ClientException + * @expectedException OAuth2\Authentication\ClientException * @expectedExceptionCode 9 */ public function test_completeAuthCodeGrant_invalidCode() @@ -877,7 +877,7 @@ class Authentication_Server_test extends PHPUnit_Framework_TestCase } /** - * @expectedException Oauth2\Authentication\ServerException + * @expectedException OAuth2\Authentication\ServerException * @expectedExceptionMessage No registered database abstractor */ public function test_noRegisteredDatabaseAbstractor() @@ -894,8 +894,8 @@ class Authentication_Server_test extends PHPUnit_Framework_TestCase } /** - * @expectedException Oauth2\Authentication\ServerException - * @expectedExceptionMessage Registered database abstractor is not an instance of Oauth2\Authentication\Database + * @expectedException OAuth2\Authentication\ServerException + * @expectedExceptionMessage Registered database abstractor is not an instance of OAuth2\Authentication\Database */ public function test_invalidRegisteredDatabaseAbstractor() { diff --git a/tests/resource/database_mock.php b/tests/resource/database_mock.php index 52c698d8..39469bac 100644 --- a/tests/resource/database_mock.php +++ b/tests/resource/database_mock.php @@ -1,6 +1,6 @@ server = new Oauth2\Resource\Server(); + $this->server = new OAuth2\Resource\Server(); $this->db = new ResourceDB(); - $this->assertInstanceOf('Oauth2\Resource\Database', $this->db); + $this->assertInstanceOf('OAuth2\Resource\Database', $this->db); $this->server->registerDbAbstractor($this->db); } @@ -72,7 +72,7 @@ class Resource_Server_test extends PHPUnit_Framework_TestCase { } /** - * @expectedException \Oauth2\Resource\ClientException + * @expectedException \OAuth2\Resource\ClientException * @expectedExceptionMessage An access token was not presented with the request */ function test_init_missingToken() @@ -81,7 +81,7 @@ class Resource_Server_test extends PHPUnit_Framework_TestCase { } /** - * @expectedException \Oauth2\Resource\ClientException + * @expectedException \OAuth2\Resource\ClientException * @expectedExceptionMessage The access token is not registered with the resource server */ function test_init_wrongToken()