You are here

public function ChainRouterTest::testMatchRequest in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 vendor/symfony-cmf/routing/Tests/Routing/ChainRouterTest.php \Symfony\Cmf\Component\Routing\Tests\Routing\ChainRouterTest::testMatchRequest()

The first usable match is used, no further routers are queried once a match is found

File

vendor/symfony-cmf/routing/Tests/Routing/ChainRouterTest.php, line 226

Class

ChainRouterTest

Namespace

Symfony\Cmf\Component\Routing\Tests\Routing

Code

public function testMatchRequest() {
  $url = '/test';
  list($lower, $low, $high) = $this
    ->createRouterMocks();
  $highest = $this
    ->getMock('Symfony\\Cmf\\Component\\Routing\\Tests\\Routing\\RequestMatcher');
  $request = Request::create('/test');
  $highest
    ->expects($this
    ->once())
    ->method('matchRequest')
    ->will($this
    ->throwException(new \Symfony\Component\Routing\Exception\ResourceNotFoundException()));
  $high
    ->expects($this
    ->once())
    ->method('match')
    ->with($url)
    ->will($this
    ->throwException(new \Symfony\Component\Routing\Exception\ResourceNotFoundException()));
  $low
    ->expects($this
    ->once())
    ->method('match')
    ->with($url)
    ->will($this
    ->returnValue(array(
    'test',
  )));
  $lower
    ->expects($this
    ->never())
    ->method('match');
  $this->router
    ->add($lower, 5);
  $this->router
    ->add($low, 10);
  $this->router
    ->add($high, 100);
  $this->router
    ->add($highest, 200);
  $result = $this->router
    ->matchRequest($request);
  $this
    ->assertEquals(array(
    'test',
  ), $result);
}