| 1 |
<?php |
| 2 |
namespace Payplug\Exception; |
| 3 |
|
| 4 |
/** |
| 5 |
* @group unit |
| 6 |
* @group ci |
| 7 |
* @group recommended |
| 8 |
*/ |
| 9 |
class HttpExceptionTest extends \PHPUnit_Framework_TestCase |
| 10 |
{ |
| 11 |
public function testToString() |
| 12 |
{ |
| 13 |
$exception = new HttpException('message_content', 'http_response_content', 808); |
| 14 |
$this->assertContains('Payplug\Exception\HttpException', (string)$exception); |
| 15 |
$this->assertContains('message_content', (string)$exception); |
| 16 |
$this->assertContains('http_response_content', (string)$exception); |
| 17 |
$this->assertContains('808', (string)$exception); |
| 18 |
} |
| 19 |
|
| 20 |
public function testGetHttpResponse() |
| 21 |
{ |
| 22 |
$exception = new HttpException('message_content', 'http_response_content', 808); |
| 23 |
$this->assertEquals('http_response_content', $exception->getHttpResponse()); |
| 24 |
} |
| 25 |
|
| 26 |
public function testGetErrorObjectWhenErrorIsJson() |
| 27 |
{ |
| 28 |
$exception = new HttpException('message_content', '{"error": "an_error"}', 808); |
| 29 |
$this->assertEquals(array('error' => 'an_error'), $exception->getErrorObject()); |
| 30 |
} |
| 31 |
|
| 32 |
public function testGetErrorObjectWhenErrorIsNotJson() |
| 33 |
{ |
| 34 |
$exception = new HttpException('message_content', '{}not_json{}', 808); |
| 35 |
$this->assertNull($exception->getErrorObject()); |
| 36 |
} |
| 37 |
} |