You are here

public function NestedMatcherTest::testNestedMatcher in Zircon Profile 8.0

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

File

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

Class

NestedMatcherTest

Namespace

Symfony\Cmf\Component\Routing\Tests\NestedMatcher

Code

public function testNestedMatcher() {
  $request = Request::create('/path/one');
  $routeCollection = new RouteCollection();
  $route = $this
    ->getMockBuilder('Symfony\\Component\\Routing\\Route')
    ->disableOriginalConstructor()
    ->getMock();
  $routeCollection
    ->add('route', $route);
  $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
    ->returnValue($routeCollection));
  $this->routeFilter2
    ->expects($this
    ->once())
    ->method('filter')
    ->with($routeCollection, $request)
    ->will($this
    ->returnValue($routeCollection));
  $this->finalMatcher
    ->expects($this
    ->once())
    ->method('finalMatch')
    ->with($routeCollection, $request)
    ->will($this
    ->returnValue(array(
    'foo' => 'bar',
  )));
  $matcher = new NestedMatcher($this->provider, $this->finalMatcher);
  $matcher
    ->addRouteFilter($this->routeFilter1);
  $matcher
    ->addRouteFilter($this->routeFilter2);
  $attributes = $matcher
    ->matchRequest($request);
  $this
    ->assertEquals(array(
    'foo' => 'bar',
  ), $attributes);
}