/**
  * Sets up this test case
  */
 public function setUp()
 {
     $this->dispatcher = $this->getMock('TYPO3\\Flow\\Mvc\\Dispatcher', array('resolveController'), array(), '', FALSE);
     $this->mockRequest = $this->getMock('TYPO3\\Flow\\Mvc\\RequestInterface');
     $this->mockResponse = $this->getMock('TYPO3\\Flow\\Http\\Response');
     $this->mockController = $this->getMock('TYPO3\\Flow\\Mvc\\Controller\\ControllerInterface', array('processRequest'));
     $this->dispatcher->expects($this->any())->method('resolveController')->will($this->returnValue($this->mockController));
 }
 /**
  * Sets up this test case
  */
 public function setUp()
 {
     $this->dispatcher = $this->getMock(\TYPO3\Flow\Mvc\Dispatcher::class, array('resolveController'), array(), '', FALSE);
     $this->mockActionRequest = $this->getMockBuilder(\TYPO3\Flow\Mvc\ActionRequest::class)->disableOriginalConstructor()->getMock();
     $this->mockActionRequest->expects($this->any())->method('isMainRequest')->will($this->returnValue(FALSE));
     $this->mockParentRequest = $this->getMockBuilder(\TYPO3\Flow\Mvc\ActionRequest::class)->disableOriginalConstructor()->getMock();
     $this->mockActionRequest->expects($this->any())->method('getParentRequest')->will($this->returnValue($this->mockParentRequest));
     $this->mockMainRequest = $this->getMockBuilder(\TYPO3\Flow\Mvc\ActionRequest::class)->disableOriginalConstructor()->getMock();
     $this->mockActionRequest->expects($this->any())->method('getMainRequest')->will($this->returnValue($this->mockMainRequest));
     $this->mockHttpRequest = $this->getMockBuilder(\TYPO3\Flow\Http\Request::class)->disableOriginalConstructor()->getMock();
     $this->mockActionRequest->expects($this->any())->method('getHttpRequest')->will($this->returnValue($this->mockHttpRequest));
     $this->mockHttpResponse = $this->getMockBuilder(\TYPO3\Flow\Http\Response::class)->disableOriginalConstructor()->getMock();
     $this->mockController = $this->getMock(\TYPO3\Flow\Mvc\Controller\ControllerInterface::class, array('processRequest'));
     $this->dispatcher->expects($this->any())->method('resolveController')->will($this->returnValue($this->mockController));
     $this->mockSecurityContext = $this->getMockBuilder(\TYPO3\Flow\Security\Context::class)->disableOriginalConstructor()->getMock();
     $this->mockFirewall = $this->getMockBuilder(\TYPO3\Flow\Security\Authorization\FirewallInterface::class)->getMock();
     $this->mockSecurityLogger = $this->getMockBuilder(\TYPO3\Flow\Log\SecurityLoggerInterface::class)->getMock();
     $this->mockObjectManager = $this->getMockBuilder(\TYPO3\Flow\Object\ObjectManagerInterface::class)->getMock();
     $this->mockObjectManager->expects($this->any())->method('get')->will($this->returnCallback(function ($className) {
         if ($className === \TYPO3\Flow\Security\Context::class) {
             return $this->mockSecurityContext;
         } elseif ($className === \TYPO3\Flow\Security\Authorization\FirewallInterface::class) {
             return $this->mockFirewall;
         } elseif ($className === \TYPO3\Flow\Log\SecurityLoggerInterface::class) {
             return $this->mockSecurityLogger;
         }
         return NULL;
     }));
     $this->inject($this->dispatcher, 'objectManager', $this->mockObjectManager);
 }
 /**
  * @test
  */
 public function handleDispatchesTheRequest()
 {
     $this->mockHttpRequest->expects($this->any())->method('getArguments')->will($this->returnValue(array()));
     $this->mockPropertyMapper->expects($this->any())->method('convert')->with('', 'array', $this->mockPropertyMappingConfiguration)->will($this->returnValue(array()));
     $this->mockDispatcher->expects($this->once())->method('dispatch')->with($this->mockActionRequest, $this->mockHttpResponse);
     $this->dispatchComponent->handle($this->mockComponentContext);
 }
 /**
  * @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(\TYPO3\Fluid\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(\TYPO3\Flow\Mvc\ActionRequest::class)->disableOriginalConstructor()->getMock();
     $this->mockObjectManager->expects($this->atLeastOnce())->method('get')->with(\TYPO3\Flow\Mvc\ActionRequest::class)->will($this->returnValue($mockActionRequest));
     $this->mockDispatcher->expects($this->once())->method('dispatch')->with($mockActionRequest, $this->mockHttpResponse);
     $this->ajaxWidgetComponent->handle($this->mockComponentContext);
 }