Skip to content

Commit 433fd15

Browse files
committed
add test testRouteParametersDefaultValue
1 parent 64c3b2a commit 433fd15

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

tests/Routing/RoutingRouteTest.php

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -867,6 +867,23 @@ public function testRouterPatternSetting(): void
867867
}
868868

869869

870+
public function testRouteParametersDefaultValue()
871+
{
872+
$router = $this->getRouter();
873+
874+
$router->get('foo/{bar?}', function ($bar = '') {
875+
return $bar;
876+
})->defaults('bar', 'foo');
877+
$this->assertEquals('foo', $router->dispatch(Request::create('foo', 'GET'))->getContent());
878+
879+
880+
$router->get('foo/{bar?}', function ($bar = '') {
881+
return $bar;
882+
})->defaults('bar', 'foo');
883+
$this->assertEquals('bar', $router->dispatch(Request::create('foo/bar', 'GET'))->getContent());
884+
}
885+
886+
870887
public function testRouteRedirect()
871888
{
872889
$router = $this->getRouter();

0 commit comments

Comments
 (0)