You are here

public function DynamicRouterTest::testEventHandlerRequest in Zircon Profile 8

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

File

vendor/symfony-cmf/routing/Tests/Routing/DynamicRouterTest.php, line 305

Class

DynamicRouterTest

Namespace

Symfony\Cmf\Component\Routing\Tests\Routing

Code

public function testEventHandlerRequest() {
  $eventDispatcher = $this
    ->buildMock('Symfony\\Component\\EventDispatcher\\EventDispatcherInterface');
  $router = new DynamicRouter($this->context, $this->matcher, $this->generator, '', $eventDispatcher);
  $that = $this;
  $eventDispatcher
    ->expects($this
    ->once())
    ->method('dispatch')
    ->with(Events::PRE_DYNAMIC_MATCH_REQUEST, $this
    ->callback(function ($event) use ($that) {
    $that
      ->assertInstanceOf('Symfony\\Cmf\\Component\\Routing\\Event\\RouterMatchEvent', $event);
    $that
      ->assertEquals($that->request, $event
      ->getRequest());
    return true;
  }));
  $routeDefaults = array(
    'foo' => 'bar',
  );
  $this->matcher
    ->expects($this
    ->once())
    ->method('match')
    ->with($this->url)
    ->will($this
    ->returnValue($routeDefaults));
  $this
    ->assertEquals($routeDefaults, $router
    ->matchRequest($this->request));
}