/**
  * @test
  */
 public function getControllerObjectNameReturnsAnEmptyStringIfTheResolvedControllerDoesNotExist()
 {
     $mockObjectManager = $this->getMock(\TYPO3\Flow\Object\ObjectManagerInterface::class);
     $mockObjectManager->expects($this->at(0))->method('getCaseSensitiveObjectName')->with('SomePackage\\Some\\Subpackage\\Controller\\SomeControllerController')->will($this->returnValue(false));
     $mockPackageManager = $this->getMock(\TYPO3\Flow\Package\PackageManager::class);
     $mockPackageManager->expects($this->any())->method('getCaseSensitivePackageKey')->with('somepackage')->will($this->returnValue('SomePackage'));
     $this->inject($this->actionRequest, 'objectManager', $mockObjectManager);
     $this->inject($this->actionRequest, 'packageManager', $mockPackageManager);
     $this->actionRequest->setControllerPackageKey('somepackage');
     $this->actionRequest->setControllerSubPackageKey('Some\\Subpackage');
     $this->actionRequest->setControllerName('SomeController');
     $this->assertEquals('', $this->actionRequest->getControllerObjectName());
 }
예제 #2
0
 /**
  * @test
  */
 public function dispatchContinuesWithNextRequestFoundInAForwardException()
 {
     $httpRequest = Request::create(new Uri('http://localhost'));
     $httpResponse = new Response();
     $mainRequest = $httpRequest->createActionRequest();
     $subRequest = new ActionRequest($mainRequest);
     $nextRequest = $httpRequest->createActionRequest();
     $mainRequest->setDispatched(TRUE);
     $mainRequest->setControllerSubPackageKey('main');
     $subRequest->setControllerSubPackageKey('sub');
     $nextRequest->setControllerSubPackageKey('next');
     $mockController = $this->getMock('TYPO3\\Flow\\Mvc\\Controller\\ControllerInterface', array('processRequest'));
     $mockController->expects($this->at(0))->method('processRequest')->will($this->returnCallback(function (ActionRequest $request) use($nextRequest) {
         $request->setDispatched(TRUE);
         $forwardException = new ForwardException();
         $forwardException->setNextRequest($nextRequest);
         throw $forwardException;
     }));
     $mockController->expects($this->at(1))->method('processRequest')->will($this->returnCallback(function (ActionRequest $request) use($nextRequest) {
         // NOTE: PhpUnit creates a clone of $nextRequest, thus $request is not the same instance as expected.
         if ($request == $nextRequest) {
             $nextRequest->setDispatched(TRUE);
         }
     }));
     $dispatcher = $this->getMock('TYPO3\\Flow\\Mvc\\Dispatcher', array('resolveController', 'emitAfterControllerInvocation'), array(), '', FALSE);
     $dispatcher->expects($this->any())->method('resolveController')->will($this->returnValue($mockController));
     $dispatcher->dispatch($subRequest, $httpResponse);
 }