From 24102f22b50bf9a14198e2578995698be2bd848b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?No=C3=ABl=20Hagestein?= <6616996+Neol3108@users.noreply.github.com> Date: Mon, 22 Apr 2024 20:48:59 +0200 Subject: [PATCH] Add route-based test --- tests/Routing/RoutingRouteTest.php | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/tests/Routing/RoutingRouteTest.php b/tests/Routing/RoutingRouteTest.php index 3811b6fd350f..259d8acc4636 100644 --- a/tests/Routing/RoutingRouteTest.php +++ b/tests/Routing/RoutingRouteTest.php @@ -42,6 +42,8 @@ use Symfony\Component\HttpKernel\Exception\NotFoundHttpException; use UnexpectedValueException; +include_once __DIR__ . '/Enums.php'; + class RoutingRouteTest extends TestCase { public function testBasicDispatchingOfRoutes() @@ -1883,6 +1885,21 @@ public function testImplicitBindingsWithOptionalParameterWithExistingKeyInUri() $this->assertSame('taylor', $router->dispatch(Request::create('foo/taylor', 'GET'))->getContent()); } + public function testOptionalBackedEnumsReturnNullWhenMissing() + { + $router = $this->getRouter(); + $router->get('foo/{bar?}', [ + 'middleware' => SubstituteBindings::class, + 'uses' => function (?CategoryBackedEnum $bar = null) { + $this->assertNull($bar); + + return 'bar'; + }, + ]); + + $router->dispatch(Request::create('foo', 'GET'))->getContent(); + } + public function testImplicitBindingsWithMissingModelHandledByMissing() { $router = $this->getRouter();