mirror of
https://github.com/elyby/oauth2-server.git
synced 2024-12-22 21:19:46 +05:30
PSR fixes
This commit is contained in:
parent
0f30b2a803
commit
df85c98e53
@ -1,18 +1,21 @@
|
||||
<?php
|
||||
|
||||
class Authentication_Server_test extends PHPUnit_Framework_TestCase {
|
||||
|
||||
function setUp()
|
||||
class Authentication_Server_test extends PHPUnit_Framework_TestCase
|
||||
{
|
||||
public function setUp()
|
||||
{
|
||||
require 'src/OAuth2/Authentication/Server.php';
|
||||
require 'src/OAuth2/Authentication/Database.php';
|
||||
|
||||
$this->oauth = new Oauth2\Authentication\Server();
|
||||
|
||||
require_once('database_mock.php');
|
||||
require_once 'database_mock.php';
|
||||
$this->oauthdb = new OAuthdb();
|
||||
$this->assertInstanceOf('Oauth2\Authentication\Database', $this->oauthdb);
|
||||
$this->oauth->registerDbAbstractor($this->oauthdb);
|
||||
}
|
||||
|
||||
function test_generateCode()
|
||||
public function test_generateCode()
|
||||
{
|
||||
$reflector = new ReflectionClass($this->oauth);
|
||||
$method = $reflector->getMethod('generateCode');
|
||||
@ -25,7 +28,7 @@ class Authentication_Server_test extends PHPUnit_Framework_TestCase {
|
||||
$this->assertNotEquals($result, $result2);
|
||||
}
|
||||
|
||||
function test_redirectUri()
|
||||
public function test_redirectUri()
|
||||
{
|
||||
$result1 = $this->oauth->redirectUri('http://example.com/foo');
|
||||
$result2 = $this->oauth->redirectUri('http://example.com/foo', array('foo' => 'bar'));
|
||||
@ -36,7 +39,7 @@ class Authentication_Server_test extends PHPUnit_Framework_TestCase {
|
||||
$this->assertEquals('http://example.com/foo#foo=bar', $result3);
|
||||
}
|
||||
|
||||
function test_checkClientAuthoriseParams_GET()
|
||||
public function test_checkClientAuthoriseParams_GET()
|
||||
{
|
||||
$_GET['client_id'] = 'test';
|
||||
$_GET['redirect_uri'] = 'http://example.com/test';
|
||||
@ -62,7 +65,7 @@ class Authentication_Server_test extends PHPUnit_Framework_TestCase {
|
||||
$this->assertEquals($expect, $result);
|
||||
}
|
||||
|
||||
function test_checkClientAuthoriseParams_PassedParams()
|
||||
public function test_checkClientAuthoriseParams_PassedParams()
|
||||
{
|
||||
unset($_GET['client_id']);
|
||||
unset($_GET['redirect_uri']);
|
||||
@ -93,7 +96,7 @@ class Authentication_Server_test extends PHPUnit_Framework_TestCase {
|
||||
* @expectedException Oauth2\Authentication\ClientException
|
||||
* @expectedExceptionCode 0
|
||||
*/
|
||||
function test_checkClientAuthoriseParams_missingClientId()
|
||||
public function test_checkClientAuthoriseParams_missingClientId()
|
||||
{
|
||||
$this->oauth->checkClientAuthoriseParams();
|
||||
}
|
||||
@ -102,7 +105,7 @@ class Authentication_Server_test extends PHPUnit_Framework_TestCase {
|
||||
* @expectedException Oauth2\Authentication\ClientException
|
||||
* @expectedExceptionCode 0
|
||||
*/
|
||||
function test_checkClientAuthoriseParams_missingRedirectUri()
|
||||
public function test_checkClientAuthoriseParams_missingRedirectUri()
|
||||
{
|
||||
$_GET['client_id'] = 'test';
|
||||
|
||||
@ -113,7 +116,7 @@ class Authentication_Server_test extends PHPUnit_Framework_TestCase {
|
||||
* @expectedException Oauth2\Authentication\ClientException
|
||||
* @expectedExceptionCode 0
|
||||
*/
|
||||
function test_checkClientAuthoriseParams_missingResponseType()
|
||||
public function test_checkClientAuthoriseParams_missingResponseType()
|
||||
{
|
||||
$_GET['client_id'] = 'test';
|
||||
$_GET['redirect_uri'] = 'http://example.com/test';
|
||||
@ -125,7 +128,7 @@ class Authentication_Server_test extends PHPUnit_Framework_TestCase {
|
||||
* @expectedException Oauth2\Authentication\ClientException
|
||||
* @expectedExceptionCode 0
|
||||
*/
|
||||
function test_checkClientAuthoriseParams_missingScopes()
|
||||
public function test_checkClientAuthoriseParams_missingScopes()
|
||||
{
|
||||
$_GET['client_id'] = 'test';
|
||||
$_GET['redirect_uri'] = 'http://example.com/test';
|
||||
@ -139,7 +142,7 @@ class Authentication_Server_test extends PHPUnit_Framework_TestCase {
|
||||
* @expectedException Oauth2\Authentication\ClientException
|
||||
* @expectedExceptionCode 4
|
||||
*/
|
||||
function test_checkClientAuthoriseParams_invalidScopes()
|
||||
public function test_checkClientAuthoriseParams_invalidScopes()
|
||||
{
|
||||
$_GET['client_id'] = 'test';
|
||||
$_GET['redirect_uri'] = 'http://example.com/test';
|
||||
@ -149,7 +152,7 @@ class Authentication_Server_test extends PHPUnit_Framework_TestCase {
|
||||
$this->oauth->checkClientAuthoriseParams();
|
||||
}
|
||||
|
||||
function test_newAuthoriseRequest()
|
||||
public function test_newAuthoriseRequest()
|
||||
{
|
||||
$result = $this->oauth->newAuthoriseRequest('user', '123', array(
|
||||
'client_id' => 'test',
|
||||
@ -165,7 +168,7 @@ class Authentication_Server_test extends PHPUnit_Framework_TestCase {
|
||||
$this->assertEquals(40, strlen($result));
|
||||
}
|
||||
|
||||
function test_newAuthoriseRequest_isUnique()
|
||||
public function test_newAuthoriseRequest_isUnique()
|
||||
{
|
||||
$result1 = $this->oauth->newAuthoriseRequest('user', '123', array(
|
||||
'client_id' => 'test',
|
||||
@ -192,7 +195,7 @@ class Authentication_Server_test extends PHPUnit_Framework_TestCase {
|
||||
$this->assertNotEquals($result1, $result2);
|
||||
}
|
||||
|
||||
function test_issueAccessToken_POST()
|
||||
public function test_issueAccessToken_POST()
|
||||
{
|
||||
$auth_code = $this->oauth->newAuthoriseRequest('user', '123', array(
|
||||
'client_id' => 'test',
|
||||
@ -219,7 +222,7 @@ class Authentication_Server_test extends PHPUnit_Framework_TestCase {
|
||||
$this->assertArrayHasKey('expires_in', $result);
|
||||
}
|
||||
|
||||
function test_issueAccessToken_PassedParams()
|
||||
public function test_issueAccessToken_PassedParams()
|
||||
{
|
||||
$auth_code = $this->oauth->newAuthoriseRequest('user', '123', array(
|
||||
'client_id' => 'test',
|
||||
@ -250,7 +253,7 @@ class Authentication_Server_test extends PHPUnit_Framework_TestCase {
|
||||
* @expectedException Oauth2\Authentication\ClientException
|
||||
* @expectedExceptionCode 0
|
||||
*/
|
||||
function test_issueAccessToken_missingGrantType()
|
||||
public function test_issueAccessToken_missingGrantType()
|
||||
{
|
||||
$this->oauth->issueAccessToken();
|
||||
}
|
||||
@ -259,7 +262,7 @@ class Authentication_Server_test extends PHPUnit_Framework_TestCase {
|
||||
* @expectedException Oauth2\Authentication\ClientException
|
||||
* @expectedExceptionCode 7
|
||||
*/
|
||||
function test_issueAccessToken_unsupportedGrantType()
|
||||
public function test_issueAccessToken_unsupportedGrantType()
|
||||
{
|
||||
$params['grant_type'] = 'blah';
|
||||
|
||||
@ -270,7 +273,7 @@ class Authentication_Server_test extends PHPUnit_Framework_TestCase {
|
||||
* @expectedException Oauth2\Authentication\ClientException
|
||||
* @expectedExceptionCode 0
|
||||
*/
|
||||
function test_completeAuthCodeGrant_missingClientId()
|
||||
public function test_completeAuthCodeGrant_missingClientId()
|
||||
{
|
||||
$reflector = new ReflectionClass($this->oauth);
|
||||
$method = $reflector->getMethod('completeAuthCodeGrant');
|
||||
@ -283,7 +286,7 @@ class Authentication_Server_test extends PHPUnit_Framework_TestCase {
|
||||
* @expectedException Oauth2\Authentication\ClientException
|
||||
* @expectedExceptionCode 0
|
||||
*/
|
||||
function test_completeAuthCodeGrant_missingClientSecret()
|
||||
public function test_completeAuthCodeGrant_missingClientSecret()
|
||||
{
|
||||
$reflector = new ReflectionClass($this->oauth);
|
||||
$method = $reflector->getMethod('completeAuthCodeGrant');
|
||||
@ -298,7 +301,7 @@ class Authentication_Server_test extends PHPUnit_Framework_TestCase {
|
||||
* @expectedException Oauth2\Authentication\ClientException
|
||||
* @expectedExceptionCode 0
|
||||
*/
|
||||
function test_completeAuthCodeGrant_missingRedirectUri()
|
||||
public function test_completeAuthCodeGrant_missingRedirectUri()
|
||||
{
|
||||
$reflector = new ReflectionClass($this->oauth);
|
||||
$method = $reflector->getMethod('completeAuthCodeGrant');
|
||||
@ -314,7 +317,7 @@ class Authentication_Server_test extends PHPUnit_Framework_TestCase {
|
||||
* @expectedException Oauth2\Authentication\ClientException
|
||||
* @expectedExceptionCode 8
|
||||
*/
|
||||
function test_completeAuthCodeGrant_invalidClient()
|
||||
public function test_completeAuthCodeGrant_invalidClient()
|
||||
{
|
||||
$reflector = new ReflectionClass($this->oauth);
|
||||
$method = $reflector->getMethod('completeAuthCodeGrant');
|
||||
@ -331,7 +334,7 @@ class Authentication_Server_test extends PHPUnit_Framework_TestCase {
|
||||
* @expectedException Oauth2\Authentication\ClientException
|
||||
* @expectedExceptionCode 0
|
||||
*/
|
||||
function test_completeAuthCodeGrant_missingCode()
|
||||
public function test_completeAuthCodeGrant_missingCode()
|
||||
{
|
||||
$reflector = new ReflectionClass($this->oauth);
|
||||
$method = $reflector->getMethod('completeAuthCodeGrant');
|
||||
@ -348,7 +351,7 @@ class Authentication_Server_test extends PHPUnit_Framework_TestCase {
|
||||
* @expectedException Oauth2\Authentication\ClientException
|
||||
* @expectedExceptionCode 9
|
||||
*/
|
||||
function test_completeAuthCodeGrant_invalidCode()
|
||||
public function test_completeAuthCodeGrant_invalidCode()
|
||||
{
|
||||
$reflector = new ReflectionClass($this->oauth);
|
||||
$method = $reflector->getMethod('completeAuthCodeGrant');
|
||||
@ -366,7 +369,7 @@ class Authentication_Server_test extends PHPUnit_Framework_TestCase {
|
||||
* @expectedException Oauth2\Authentication\ServerException
|
||||
* @expectedExceptionMessage No registered database abstractor
|
||||
*/
|
||||
function test_noRegisteredDatabaseAbstractor()
|
||||
public function test_noRegisteredDatabaseAbstractor()
|
||||
{
|
||||
$reflector = new ReflectionClass($this->oauth);
|
||||
$method = $reflector->getMethod('_dbCall');
|
||||
@ -383,7 +386,7 @@ class Authentication_Server_test extends PHPUnit_Framework_TestCase {
|
||||
* @expectedException Oauth2\Authentication\ServerException
|
||||
* @expectedExceptionMessage Registered database abstractor is not an instance of Oauth2\Authentication\Database
|
||||
*/
|
||||
function test_invalidRegisteredDatabaseAbstractor()
|
||||
public function test_invalidRegisteredDatabaseAbstractor()
|
||||
{
|
||||
$fake = new stdClass;
|
||||
$this->oauth->registerDbAbstractor($fake);
|
||||
|
Loading…
Reference in New Issue
Block a user