public function NestedMatcherTest::testNestedMatcher

File

drupal/core/vendor/symfony-cmf/routing/Symfony/Cmf/Component/Routing/Tests/NestedMatcher/NestedMatcherTest.php, line 30

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);
  $matcher
    ->addRouteFilter($this->routeFilter1);
  $matcher
    ->addRouteFilter($this->routeFilter2);
  $matcher
    ->setFinalMatcher($this->finalMatcher);
  $attributes = $matcher
    ->matchRequest($request);
  $this
    ->assertEquals(array(
    'foo' => 'bar',
  ), $attributes);
}