/** * Tests that the ParamFetcher can be injected by the default name * ($paramFetcher) or by a different name if type-hinted. * * @dataProvider setParamFetcherByTypehintProvider */ public function testSettingParamFetcherByTypehint($actionName, $expectedAttribute) { $request = new Request(); $event = $this->getEvent($request, $actionName); $this->paramFetcher->expects($this->once())->method('all')->will($this->returnValue(array())); $this->paramFetcherListener->onKernelController($event); $this->assertSame($this->paramFetcher, $request->attributes->get($expectedAttribute)); }
/** * Tests that the ParamFetcher can be injected in a invokable controller. */ public function testSettingParamFetcherForInvokable() { $request = new Request(); $event = $this->getMockBuilder('Symfony\\Component\\HttpKernel\\Event\\FilterControllerEvent')->disableOriginalConstructor()->getMock(); $event->expects($this->atLeastOnce())->method('getRequest')->will($this->returnValue($request)); $controller = new ParamFetcherController(); $event->expects($this->atLeastOnce())->method('getController')->will($this->returnValue($controller)); $this->paramFetcher->expects($this->once())->method('all')->will($this->returnValue(array())); $this->paramFetcherListener->onKernelController($event); $this->assertSame($this->paramFetcher, $request->attributes->get('pfInvokable')); }