Added method to get the exception type

This commit is contained in:
Alex Bilbie 2013-02-15 16:29:00 +00:00
parent 9f6bd64100
commit 92d9435bba
2 changed files with 17 additions and 1 deletions

View File

@ -67,7 +67,7 @@ class AuthServer
* Exception error codes
* @var array
*/
protected $exceptionCodes = array(
protected static $exceptionCodes = array(
0 => 'invalid_request',
1 => 'unauthorized_client',
2 => 'access_denied',
@ -110,6 +110,17 @@ class AuthServer
return self::$exceptionMessages[$error];
}
/**
* Get an exception code
*
* @param integer $code The exception code
* @return string The exception code type
*/
public static function getExceptionType($code = 0)
{
return self::$exceptionCodes[$code];
}
/**
* Create a new OAuth2 authentication server
*

View File

@ -45,6 +45,11 @@ class Authentication_Server_test extends PHPUnit_Framework_TestCase
$this->assertEquals($v['access_denied'], $m);
}
public function test_getExceptionCode()
{
$this->assertEquals('access_denied', OAuth2\AuthServer::getExceptionType(2));
}
public function test_hasGrantType()
{
$this->assertFalse(OAuth2\AuthServer::hasGrantType('test'));