Merge branch 'geofflancaster-patch' into geofflancaster-idpexception-empty-strings

Conflicts:
	test/src/Exception/IDPExceptionTest.php
oauth1test
Ben Ramsey 2015-03-10 16:01:48 -05:00
commit 248f55c201
2 changed files with 30 additions and 2 deletions

View File

@ -12,10 +12,10 @@ class IDPException extends \Exception
$code = isset($result['code']) ? $result['code'] : 0;
if (isset($result['error'])) {
if (isset($result['error']) && $result['error'] !== '') {
// OAuth 2.0 Draft 10 style
$message = $result['error'];
} elseif (isset($result['message'])) {
} elseif (isset($result['message']) && $result['message'] !== '') {
// cURL style
$message = $result['message'];
} else {

View File

@ -54,4 +54,32 @@ class IDPExceptionTest extends \PHPUnit_Framework_TestCase
$exception->getResponseBody()
);
}
public function testEmptyMessage()
{
$exception = new IDPException(array('error' => 'error_message', 'message' => ''));
// message should be the error text since message isn't specifically defined
$this->assertEquals('error_message', $exception->getMessage());
}
public function testNonEmptyMessage()
{
$exception = new IDPException(array('error' => 'error_message', 'message' => 'message'));
// message should be the error text since message isn't specifically defined
$this->assertEquals('message', $exception->getMessage());
}
public function testEmptyError()
{
$exception = new IDPException(array('error' => '', 'message' => 'message'));
// message should be the error text since message isn't specifically defined
$this->assertEquals('message', $exception->getMessage());
}
public function testEmptyAndMessage()
{
$exception = new IDPException(array('error' => '', 'message' => ''));
// message should be the error text since message isn't specifically defined
$this->assertEquals('Unknown Error.', $exception->getMessage());
}
}