/** * @test */ public function handleDispatchesTheRequest() { $this->mockHttpRequest->expects($this->any())->method('getArguments')->will($this->returnValue([])); $this->mockPropertyMapper->expects($this->any())->method('convert')->with('', 'array', $this->mockPropertyMappingConfiguration)->will($this->returnValue([])); $this->mockDispatcher->expects($this->once())->method('dispatch')->with($this->mockActionRequest, $this->mockHttpResponse); $this->dispatchComponent->handle($this->mockComponentContext); }
/** * Sets up this test case */ public function setUp() { $this->dispatcher = $this->getMockBuilder(Dispatcher::class)->disableOriginalConstructor()->setMethods(['resolveController'])->getMock(); $this->mockActionRequest = $this->getMockBuilder(ActionRequest::class)->disableOriginalConstructor()->getMock(); $this->mockActionRequest->expects($this->any())->method('isMainRequest')->will($this->returnValue(false)); $this->mockParentRequest = $this->getMockBuilder(ActionRequest::class)->disableOriginalConstructor()->getMock(); $this->mockActionRequest->expects($this->any())->method('getParentRequest')->will($this->returnValue($this->mockParentRequest)); $this->mockMainRequest = $this->getMockBuilder(ActionRequest::class)->disableOriginalConstructor()->getMock(); $this->mockActionRequest->expects($this->any())->method('getMainRequest')->will($this->returnValue($this->mockMainRequest)); $this->mockHttpRequest = $this->getMockBuilder(HttpRequest::class)->disableOriginalConstructor()->getMock(); $this->mockActionRequest->expects($this->any())->method('getHttpRequest')->will($this->returnValue($this->mockHttpRequest)); $this->mockHttpResponse = $this->getMockBuilder(HttpResponse::class)->disableOriginalConstructor()->getMock(); $this->mockController = $this->getMockBuilder(ControllerInterface::class)->setMethods(['processRequest'])->getMock(); $this->dispatcher->expects($this->any())->method('resolveController')->will($this->returnValue($this->mockController)); $this->mockSecurityContext = $this->getMockBuilder(Context::class)->disableOriginalConstructor()->getMock(); $this->mockFirewall = $this->getMockBuilder(FirewallInterface::class)->getMock(); $this->mockSecurityLogger = $this->getMockBuilder(SecurityLoggerInterface::class)->getMock(); $this->mockObjectManager = $this->getMockBuilder(ObjectManagerInterface::class)->getMock(); $this->mockObjectManager->expects($this->any())->method('get')->will($this->returnCallback(function ($className) { if ($className === Context::class) { return $this->mockSecurityContext; } elseif ($className === FirewallInterface::class) { return $this->mockFirewall; } elseif ($className === SecurityLoggerInterface::class) { return $this->mockSecurityLogger; } return null; })); $this->inject($this->dispatcher, 'objectManager', $this->mockObjectManager); }
/** * @test */ public function handleDispatchesActionRequestIfWidgetContextIsPresent() { $mockWidgetId = 'SomeWidgetId'; $mockControllerObjectName = 'SomeControllerObjectName'; $this->mockHttpRequest->expects($this->at(0))->method('hasArgument')->with('__widgetId')->will($this->returnValue(true)); $this->mockHttpRequest->expects($this->atLeastOnce())->method('getArgument')->with('__widgetId')->will($this->returnValue($mockWidgetId)); $mockWidgetContext = $this->getMockBuilder(\Neos\FluidAdaptor\Core\Widget\WidgetContext::class)->getMock(); $mockWidgetContext->expects($this->atLeastOnce())->method('getControllerObjectName')->will($this->returnValue($mockControllerObjectName)); $this->mockAjaxWidgetContextHolder->expects($this->atLeastOnce())->method('get')->with($mockWidgetId)->will($this->returnValue($mockWidgetContext)); $mockActionRequest = $this->getMockBuilder(\Neos\Flow\Mvc\ActionRequest::class)->disableOriginalConstructor()->getMock(); $this->mockObjectManager->expects($this->atLeastOnce())->method('get')->with(\Neos\Flow\Mvc\ActionRequest::class)->will($this->returnValue($mockActionRequest)); $this->mockDispatcher->expects($this->once())->method('dispatch')->with($mockActionRequest, $this->mockHttpResponse); $this->ajaxWidgetComponent->handle($this->mockComponentContext); }