You are here

public function UrlMatcherTest::testOptionalVariableWithNoRealSeparator in Zircon Profile 8.0

Same name and namespace in other branches
  1. 8 vendor/symfony/routing/Tests/Matcher/UrlMatcherTest.php \Symfony\Component\Routing\Tests\Matcher\UrlMatcherTest::testOptionalVariableWithNoRealSeparator()

File

vendor/symfony/routing/Tests/Matcher/UrlMatcherTest.php, line 258

Class

UrlMatcherTest

Namespace

Symfony\Component\Routing\Tests\Matcher

Code

public function testOptionalVariableWithNoRealSeparator() {
  $coll = new RouteCollection();
  $coll
    ->add('test', new Route('/get{what}', array(
    'what' => 'All',
  )));
  $matcher = new UrlMatcher($coll, new RequestContext());
  $this
    ->assertEquals(array(
    'what' => 'All',
    '_route' => 'test',
  ), $matcher
    ->match('/get'));
  $this
    ->assertEquals(array(
    'what' => 'Sites',
    '_route' => 'test',
  ), $matcher
    ->match('/getSites'));

  // Usually the character in front of an optional parameter can be left out, e.g. with pattern '/get/{what}' just '/get' would match.
  // But here the 't' in 'get' is not a separating character, so it makes no sense to match without it.
  $this
    ->setExpectedException('Symfony\\Component\\Routing\\Exception\\ResourceNotFoundException');
  $matcher
    ->match('/ge');
}