/** * @dataProvider generateGenerator */ public function testGenerate($resource, array $params) { $currentRouteName = 'my_route'; $currentRouteParams = array('foo' => 'bar'); $request = new Request(); $request->attributes->set('_route', $currentRouteName); $request->attributes->set('_route_params', $currentRouteParams); $event = new RouteReferenceGenerationEvent(new RouteReference($resource, $params), $request); $this->dispatcher->expects($this->once())->method('dispatch')->with(MVCEvents::ROUTE_REFERENCE_GENERATION, $this->equalTo($event)); $generator = new RouteReferenceGenerator($this->dispatcher); $generator->setRequest($request); $reference = $generator->generate($resource, $params); $this->assertInstanceOf('eZ\\Publish\\Core\\MVC\\Symfony\\Routing\\RouteReference', $reference); $this->assertSame($resource, $reference->getRoute()); $this->assertSame($params, $reference->getParams()); }
protected function getRouteReferenceGenerator() { $generator = new RouteReferenceGenerator($this->getMock('Symfony\\Component\\EventDispatcher\\EventDispatcherInterface')); $generator->setRequest(new Request()); return $generator; }