Skip to content

Commit

Permalink
Add missing tests
Browse files Browse the repository at this point in the history
Signed-off-by: Luís Cobucci <[email protected]>
  • Loading branch information
lcobucci committed Jan 8, 2024
1 parent 4be1beb commit ab04b7c
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions test/Dispatcher/DispatcherTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@
use FastRoute\BadRouteException;
use FastRoute\DataGenerator;
use FastRoute\Dispatcher;
use FastRoute\Dispatcher\Result\Matched;
use FastRoute\Dispatcher\Result\MethodNotAllowed;
use FastRoute\Dispatcher\Result\NotMatched;
use FastRoute\RouteCollector;
use PHPUnit\Framework\Attributes as PHPUnit;
use PHPUnit\Framework\TestCase;
Expand Down Expand Up @@ -55,6 +58,11 @@ public function foundDispatches(
$dispatcher = simpleDispatcher($callback, $this->generateDispatcherOptions());
$info = $dispatcher->dispatch($method, $uri);

self::assertInstanceOf(Matched::class, $info);
self::assertSame($handler, $info->handler);
self::assertSame($argDict, $info->variables);

// BC-compatibility checks
self::assertSame($dispatcher::FOUND, $info[0]);
self::assertSame($handler, $info[1]);
self::assertSame($argDict, $info[2]);
Expand All @@ -66,6 +74,10 @@ public function notFoundDispatches(string $method, string $uri, callable $callba
{
$dispatcher = simpleDispatcher($callback, $this->generateDispatcherOptions());
$routeInfo = $dispatcher->dispatch($method, $uri);

self::assertInstanceOf(NotMatched::class, $routeInfo);

// BC-compatibility checks
self::assertArrayNotHasKey(
1,
$routeInfo,
Expand All @@ -85,6 +97,11 @@ public function methodNotAllowedDispatches(
): void {
$dispatcher = simpleDispatcher($callback, $this->generateDispatcherOptions());
$routeInfo = $dispatcher->dispatch($method, $uri);

self::assertInstanceOf(MethodNotAllowed::class, $routeInfo);
self::assertSame($availableMethods, $routeInfo->allowedMethods);

// BC-compatibility checks
self::assertArrayHasKey(
1,
$routeInfo,
Expand Down

0 comments on commit ab04b7c

Please sign in to comment.