Skip to content

Commit d5a038e

Browse files
Merge branch '6.4' into 7.2
* 6.4: [Routing] Add test to validate that default value is allowed to not match requirement fix handling required options Fix @var phpdoc [Lock] [MongoDB] Enforce readPreference=primary and writeConcern=majority [FrameworkBundle] fix phpdoc in `MicroKernelTrait` Fixed validator translations for Albanian
2 parents 3746004 + e4f94e6 commit d5a038e

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

Tests/Matcher/UrlMatcherTest.php

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1000,6 +1000,30 @@ public function testUtf8VarName()
10001000
$this->assertEquals(['_route' => 'foo', 'bär' => 'baz', 'bäz' => 'foo'], $matcher->match('/foo/baz'));
10011001
}
10021002

1003+
public function testParameterWithRequirementWithDefault()
1004+
{
1005+
$collection = new RouteCollection();
1006+
1007+
$route = new Route('/test/{foo}', ['foo' => 'foo-'], ['foo' => '\w+']);
1008+
$collection->add('test', $route);
1009+
1010+
$matcher = $this->getUrlMatcher($collection);
1011+
1012+
$result = $matcher->match('/test/foo');
1013+
$this->assertSame('test', $result['_route']);
1014+
$this->assertSame('foo', $result['foo']);
1015+
1016+
try {
1017+
$matcher->match('/test/foo-');
1018+
} catch (ResourceNotFoundException $e) {
1019+
$this->assertStringContainsString('No routes found', $e->getMessage());
1020+
}
1021+
1022+
$result = $matcher->match('/test');
1023+
$this->assertSame('test', $result['_route']);
1024+
$this->assertSame('foo-', $result['foo']);
1025+
}
1026+
10031027
public function testMapping()
10041028
{
10051029
$collection = new RouteCollection();

0 commit comments

Comments
 (0)