You are here

public function ChainRouterTest::testMatchRequestAndNotAllowed 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::testMatchRequestAndNotAllowed()

If there is a method not allowed but another router matches, that one is used

File

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

Class

ChainRouterTest

Namespace

Symfony\Cmf\Component\Routing\Tests\Routing

Code

public function testMatchRequestAndNotAllowed() {
  $url = '/test';
  list($low, $high) = $this
    ->createRouterMocks();
  $high
    ->expects($this
    ->once())
    ->method('match')
    ->with($url)
    ->will($this
    ->throwException(new \Symfony\Component\Routing\Exception\MethodNotAllowedException(array())));
  $low
    ->expects($this
    ->once())
    ->method('match')
    ->with($url)
    ->will($this
    ->returnValue(array(
    'test',
  )));
  $this->router
    ->add($low, 10);
  $this->router
    ->add($high, 100);
  $result = $this->router
    ->matchRequest(Request::create('/test'));
  $this
    ->assertEquals(array(
    'test',
  ), $result);
}