You are here

public function ChainRouterTest::testMatch in Zircon Profile 8.0

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

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 195

Class

ChainRouterTest

Namespace

Symfony\Cmf\Component\Routing\Tests\Routing

Code

public function testMatch() {
  $url = '/test';
  list($lower, $low, $high) = $this
    ->createRouterMocks();
  $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);
  $result = $this->router
    ->match('/test');
  $this
    ->assertEquals(array(
    'test',
  ), $result);
}