Exceptions: Added HttpNotFound exception

This commit is contained in:
Igor Scheller 2019-10-07 22:02:28 +02:00
parent 8d090438b6
commit 1b3e3b1d65
2 changed files with 45 additions and 0 deletions

View File

@ -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);
}
}

View File

@ -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());
}
}