coverage of exception
parent
781be84aa4
commit
7f4f5a501d
|
@ -27,16 +27,18 @@ class IDPException extends \Exception
|
|||
|
||||
public function getType()
|
||||
{
|
||||
$result = 'Exception';
|
||||
|
||||
if (isset($this->result['error'])) {
|
||||
$message = $this->result['error'];
|
||||
|
||||
if (is_string($message)) {
|
||||
// OAuth 2.0 Draft 10 style
|
||||
return $message;
|
||||
$result = $message;
|
||||
}
|
||||
}
|
||||
|
||||
return 'Exception';
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -0,0 +1,44 @@
|
|||
<?php
|
||||
|
||||
namespace League\OAuth2\Client\Test\Exception;
|
||||
|
||||
use League\OAuth2\Client\Exception\IDPException;
|
||||
|
||||
class IDPExceptionTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
|
||||
public function testGetTypeErrorMessage()
|
||||
{
|
||||
$exception = new IDPException(array('error' => 'message'));
|
||||
|
||||
$this->assertEquals('message', $exception->getType());
|
||||
}
|
||||
|
||||
public function testGetTypeMessage()
|
||||
{
|
||||
$exception = new IDPException(array('message' => 'message'));
|
||||
|
||||
$this->assertEquals('Exception', $exception->getType());
|
||||
}
|
||||
|
||||
public function testGetTypeEmpty()
|
||||
{
|
||||
$exception = new IDPException([]);
|
||||
|
||||
$this->assertEquals('Exception', $exception->getType());
|
||||
}
|
||||
|
||||
public function testAsString()
|
||||
{
|
||||
$exception = new IDPException(array('error' => 'message'));
|
||||
|
||||
$this->assertEquals('message: message', (string)$exception);
|
||||
}
|
||||
|
||||
public function testAsStringWithCode()
|
||||
{
|
||||
$exception = new IDPException(array('error' => 'message', 'code' => 404));
|
||||
|
||||
$this->assertEquals('message: 404: message', (string)$exception);
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue