Skip to content

Commit b7b288c

Browse files
Анатолий НехайАнатолий Нехай
authored andcommitted
PageNotFoundException was added
1 parent 4c94f68 commit b7b288c

File tree

4 files changed

+99
-1
lines changed

4 files changed

+99
-1
lines changed
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
<?php declare(strict_types=1);
2+
3+
/**
4+
* It's free open-source software released under the MIT License.
5+
*
6+
* @author Anatoly Fenric <[email protected]>
7+
* @copyright Copyright (c) 2018, Anatoly Fenric
8+
* @license https://github.com/sunrise-php/http-router/blob/master/LICENSE
9+
* @link https://github.com/sunrise-php/http-router
10+
*/
11+
12+
namespace Sunrise\Http\Router\Exception;
13+
14+
/**
15+
* PageNotFoundException
16+
*
17+
* @since 2.4.2
18+
*/
19+
class PageNotFoundException extends Exception
20+
{
21+
}

src/Exception/RouteNotFoundException.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,6 @@
1414
/**
1515
* RouteNotFoundException
1616
*/
17-
class RouteNotFoundException extends Exception
17+
class RouteNotFoundException extends PageNotFoundException
1818
{
1919
}
Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
<?php declare(strict_types=1);
2+
3+
namespace Sunrise\Http\Router\Tests\Exception;
4+
5+
/**
6+
* Import classes
7+
*/
8+
use PHPUnit\Framework\TestCase;
9+
use Sunrise\Http\Router\Exception\Exception;
10+
use Sunrise\Http\Router\Exception\PageNotFoundException;
11+
12+
/**
13+
* PageNotFoundExceptionTest
14+
*/
15+
class PageNotFoundExceptionTest extends TestCase
16+
{
17+
18+
/**
19+
* @return void
20+
*/
21+
public function testConstructor() : void
22+
{
23+
$exception = new PageNotFoundException();
24+
25+
$this->assertInstanceOf(Exception::class, $exception);
26+
}
27+
28+
/**
29+
* @return void
30+
*/
31+
public function testMessage() : void
32+
{
33+
$message = 'blah';
34+
35+
$exception = new PageNotFoundException($message);
36+
37+
$this->assertSame($message, $exception->getMessage());
38+
}
39+
40+
/**
41+
* @return void
42+
*/
43+
public function testContext() : void
44+
{
45+
$context = ['foo' => 'bar'];
46+
47+
$exception = new PageNotFoundException('blah', $context);
48+
49+
$this->assertSame($context, $exception->getContext());
50+
}
51+
52+
/**
53+
* @return void
54+
*/
55+
public function testCode() : void
56+
{
57+
$code = 100;
58+
59+
$exception = new PageNotFoundException('blah', [], $code);
60+
61+
$this->assertSame($code, $exception->getCode());
62+
}
63+
64+
/**
65+
* @return void
66+
*/
67+
public function testPrevious() : void
68+
{
69+
$previous = new \Exception();
70+
71+
$exception = new PageNotFoundException('blah', [], 0, $previous);
72+
73+
$this->assertSame($previous, $exception->getPrevious());
74+
}
75+
}

tests/Exception/RouteNotFoundExceptionTest.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
*/
88
use PHPUnit\Framework\TestCase;
99
use Sunrise\Http\Router\Exception\Exception;
10+
use Sunrise\Http\Router\Exception\PageNotFoundException;
1011
use Sunrise\Http\Router\Exception\RouteNotFoundException;
1112

1213
/**
@@ -23,6 +24,7 @@ public function testConstructor() : void
2324
$exception = new RouteNotFoundException();
2425

2526
$this->assertInstanceOf(Exception::class, $exception);
27+
$this->assertInstanceOf(PageNotFoundException::class, $exception);
2628
}
2729

2830
/**

0 commit comments

Comments
 (0)