Skip to content

Commit

Permalink
Add route-based test
Browse files Browse the repository at this point in the history
  • Loading branch information
Neol3108 committed Apr 22, 2024
1 parent 5505370 commit 24102f2
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions tests/Routing/RoutingRouteTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
use UnexpectedValueException;

include_once __DIR__ . '/Enums.php';

class RoutingRouteTest extends TestCase
{
public function testBasicDispatchingOfRoutes()
Expand Down Expand Up @@ -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();
Expand Down

0 comments on commit 24102f2

Please sign in to comment.