You are here

public function NestedMatcherTest::testNestedMatcherPriority in Zircon Profile 8

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

Test priorities and exception handling

File

vendor/symfony-cmf/routing/Tests/NestedMatcher/NestedMatcherTest.php, line 79

Class

NestedMatcherTest

Namespace

Symfony\Cmf\Component\Routing\Tests\NestedMatcher

Code

public function testNestedMatcherPriority() {
  $request = Request::create('/path/one');
  $routeCollection = new RouteCollection();
  $route = $this
    ->getMockBuilder('Symfony\\Component\\Routing\\Route')
    ->disableOriginalConstructor()
    ->getMock();
  $routeCollection
    ->add('route', $route);
  $wrongProvider = $this
    ->buildMock('Symfony\\Cmf\\Component\\Routing\\RouteProviderInterface');
  $wrongProvider
    ->expects($this
    ->never())
    ->method('getRouteCollectionForRequest');
  $this->provider
    ->expects($this
    ->once())
    ->method('getRouteCollectionForRequest')
    ->with($request)
    ->will($this
    ->returnValue($routeCollection));
  $this->routeFilter1
    ->expects($this
    ->once())
    ->method('filter')
    ->with($routeCollection, $request)
    ->will($this
    ->throwException(new ResourceNotFoundException()));
  $this->routeFilter2
    ->expects($this
    ->never())
    ->method('filter');
  $this->finalMatcher
    ->expects($this
    ->never())
    ->method('finalMatch');
  $matcher = new NestedMatcher($wrongProvider, $this->finalMatcher);
  $matcher
    ->setRouteProvider($this->provider);
  $matcher
    ->addRouteFilter($this->routeFilter2, 10);
  $matcher
    ->addRouteFilter($this->routeFilter1, 20);
  try {
    $matcher
      ->matchRequest($request);
    fail('nested matcher is eating exception');
  } catch (ResourceNotFoundException $e) {

    // expected
  }
}