diff --git a/src/Routing/Route.php b/src/Routing/Route.php index f3eb05a0..e4532e8d 100644 --- a/src/Routing/Route.php +++ b/src/Routing/Route.php @@ -300,6 +300,12 @@ private function preprocessParams(array &$params): bool $fixity = $meta[self::FIXITY] ?? null; if (!isset($params[$name])) { + if ($fixity === self::CONSTANT) { + if ($meta[self::VALUE] === null) { + continue; + } + return false; // wrong parameter value + } continue; // retains null values } diff --git a/tests/Route/fixedParameter.phpt b/tests/Route/fixedParameter.phpt index c3fd4ed8..0d9b437d 100644 --- a/tests/Route/fixedParameter.phpt +++ b/tests/Route/fixedParameter.phpt @@ -21,10 +21,7 @@ testRouteIn($route, '/?const=foo', ['const' => 'hello', 'test' => 'testvalue'], testRouteIn($route, '/?const=hello', ['const' => 'hello', 'test' => 'testvalue'], '/?test=testvalue'); -Assert::same( - 'http://example.com/', - testRouteOut($route, []) -); +Assert::null(testRouteOut($route, [])); Assert::null(testRouteOut($route, ['const' => 'foo'])); @@ -33,7 +30,4 @@ Assert::same( testRouteOut($route, ['const' => 'hello']) ); -Assert::same( - 'http://example.com/', - testRouteOut($route, ['const' => null]) -); +Assert::null(testRouteOut($route, ['const' => null])); diff --git a/tests/Route/optional.autooptional3.phpt b/tests/Route/optional.autooptional3.phpt index 03a04328..6a422cf3 100644 --- a/tests/Route/optional.autooptional3.phpt +++ b/tests/Route/optional.autooptional3.phpt @@ -13,9 +13,7 @@ use Tester\Assert; require __DIR__ . '/../bootstrap.php'; -$route = new Route('//', [ - 'action' => 'default', -]); +$route = new Route('//', []); testRouteIn($route, '/presenter/'); testRouteIn($route, '/presenter/abc'); @@ -24,7 +22,6 @@ testRouteIn($route, '/presenter/abc/'); testRouteIn($route, '/presenter/abc/xyy', [ 'presenter' => 'presenter', 'default' => 'abc', - 'action' => 'default', 'test' => 'testvalue', 'required' => 'xyy', ], '/presenter/abc/xyy?test=testvalue');