Skip to content

Commit 000b4f1

Browse files
committed
create route test
1 parent 9b73c4b commit 000b4f1

File tree

1 file changed

+16
-1
lines changed

1 file changed

+16
-1
lines changed

tests/Route/RouterTest.php

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,23 @@
33
namespace App\Test\Route;
44

55
use App\Route\Router;
6+
use InvalidArgumentException;
7+
use PHPUnit\Framework\TestCase;
68

7-
class RouterTest extends \PHPUnit_Framework_TestCase
9+
class RouterTest extends TestCase
810
{
11+
public function test_RouteDispatch_ShouldThrowInvalidArgumentException_WhenGivenAnUnregisteredRoute(): void
12+
{
13+
$unregisteredRoute = '/unregistered-route';
14+
$notFoundCode = 204;
915

16+
$route = new Router();
17+
$route->registry('/user', \App\User\UserController::class, 'index');
18+
19+
$this->expectException(InvalidArgumentException::class);
20+
$this->expectExceptionMessage("'{$unregisteredRoute}' is an unregistered route");
21+
$this->expectExceptionCode($notFoundCode);
22+
23+
$route->dispatch($unregisteredRoute);
24+
}
1025
}

0 commit comments

Comments
 (0)