diff options
author | Igor Scheller <igor.scheller@igorshp.de> | 2019-10-07 22:02:28 +0200 |
---|---|---|
committer | Igor Scheller <igor.scheller@igorshp.de> | 2019-10-07 22:02:28 +0200 |
commit | 1b3e3b1d65126da909d0013c9c0a0cb3f41639c1 (patch) | |
tree | 9c249a880acfa8c9cbab48989ad33ba7d05f0f30 | |
parent | 8d090438b659b641dd0f6cbc99193f3b48b2fc4b (diff) |
Exceptions: Added HttpNotFound exception
-rw-r--r-- | src/Http/Exceptions/HttpNotFound.php | 23 | ||||
-rw-r--r-- | tests/Unit/Http/Exceptions/HttpNotFoundTest.php | 22 |
2 files changed, 45 insertions, 0 deletions
diff --git a/src/Http/Exceptions/HttpNotFound.php b/src/Http/Exceptions/HttpNotFound.php new file mode 100644 index 00000000..324adaf9 --- /dev/null +++ b/src/Http/Exceptions/HttpNotFound.php @@ -0,0 +1,23 @@ +<?php + +namespace Engelsystem\Http\Exceptions; + +use Throwable; + +class HttpNotFound extends HttpException +{ + /** + * @param string $message + * @param array $headers + * @param int $code + * @param Throwable|null $previous + */ + public function __construct( + string $message = '', + array $headers = [], + int $code = 0, + Throwable $previous = null + ) { + parent::__construct(404, $message, $headers, $code, $previous); + } +} diff --git a/tests/Unit/Http/Exceptions/HttpNotFoundTest.php b/tests/Unit/Http/Exceptions/HttpNotFoundTest.php new file mode 100644 index 00000000..a39ea087 --- /dev/null +++ b/tests/Unit/Http/Exceptions/HttpNotFoundTest.php @@ -0,0 +1,22 @@ +<?php + +namespace Engelsystem\Test\Unit\Http\Exceptions; + +use Engelsystem\Http\Exceptions\HttpNotFound; +use PHPUnit\Framework\TestCase; + +class HttpNotFoundTest extends TestCase +{ + /** + * @covers \Engelsystem\Http\Exceptions\HttpNotFound::__construct + */ + public function testConstruct() + { + $exception = new HttpNotFound(); + $this->assertEquals(404, $exception->getStatusCode()); + $this->assertEquals('', $exception->getMessage()); + + $exception = new HttpNotFound('Nothing to see here!'); + $this->assertEquals('Nothing to see here!', $exception->getMessage()); + } +} |