From ab04b7c0ae3b0a6b412d3d07ad9a4137870f7254 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lu=C3=ADs=20Cobucci?= Date: Mon, 8 Jan 2024 22:47:38 +0100 Subject: [PATCH] Add missing tests MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Luís Cobucci --- test/Dispatcher/DispatcherTestCase.php | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/test/Dispatcher/DispatcherTestCase.php b/test/Dispatcher/DispatcherTestCase.php index 66bc06d..be3eb7f 100644 --- a/test/Dispatcher/DispatcherTestCase.php +++ b/test/Dispatcher/DispatcherTestCase.php @@ -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; @@ -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]); @@ -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, @@ -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,