Beispiel #1
0
 /**
  * Sets up this test case
  *
  */
 public function setUp()
 {
     $this->mockObjectManager = $this->getMock('TYPO3\\FLOW3\\Object\\ObjectManagerInterface');
     $this->mockObjectManager->expects($this->any())->method('create')->will($this->returnCallback(array($this, 'objectManagerCallBack')));
     $this->route = $this->getAccessibleMock('TYPO3\\FLOW3\\Mvc\\Routing\\Route', array('dummy'));
     $this->route->_set('objectManager', $this->mockObjectManager);
     $this->mockRouter = $this->getMock('TYPO3\\FLOW3\\Mvc\\Routing\\RouterInterface');
     $this->mockRouter->expects($this->any())->method('getControllerObjectName')->will($this->returnValue('SomeControllerObjectName'));
     $this->route->injectRouter($this->mockRouter);
     $this->mockPersistenceManager = $this->getMock('TYPO3\\FLOW3\\Persistence\\PersistenceManagerInterface');
     $this->mockPersistenceManager->expects($this->any())->method('convertObjectsToIdentityArrays')->will($this->returnCallback(function ($array) {
         return $array;
     }));
     $this->route->injectPersistenceManager($this->mockPersistenceManager);
 }
Beispiel #2
0
 /**
  * @test
  */
 public function buildPrependsIndexFileIfRewriteUrlsIsOff()
 {
     $this->mockRouter->expects($this->once())->method('resolve')->will($this->returnValue('resolvedUri'));
     $mockEnvironment = $this->getMock('TYPO3\\FLOW3\\Utility\\Environment', array('isRewriteEnabled'), array(), '', FALSE);
     $this->uriBuilder->injectEnvironment($mockEnvironment);
     $expectedResult = 'index.php/resolvedUri';
     $actualResult = $this->uriBuilder->build();
     $this->assertEquals($expectedResult, $actualResult);
 }
Beispiel #3
0
 /**
  * Builds the URI
  *
  * @param array $arguments optional URI arguments. Will be merged with $this->arguments with precedence to $arguments
  * @return string The URI
  * @api
  */
 public function build(array $arguments = array())
 {
     $arguments = Arrays::arrayMergeRecursiveOverrule($this->arguments, $arguments);
     $this->mergeArgumentsWithRequestArguments($arguments);
     $uri = $this->router->resolve($arguments);
     $this->lastArguments = $arguments;
     if (!$this->environment->isRewriteEnabled()) {
         $uri = 'index.php/' . $uri;
     }
     if ($this->createAbsoluteUri === TRUE) {
         $uri = $this->request->getHttpRequest()->getBaseUri() . $uri;
     }
     if ($this->section !== '') {
         $uri .= '#' . $this->section;
     }
     return $uri;
 }
 /**
  * Initialize the injected router-object
  *
  * @return void
  */
 protected function initializeRouter()
 {
     $routesConfiguration = $this->configurationManager->getConfiguration(\TYPO3\FLOW3\Configuration\ConfigurationManager::CONFIGURATION_TYPE_ROUTES);
     $this->router->setRoutesConfiguration($routesConfiguration);
 }
Beispiel #5
0
 /**
  * Try to get the controller object name from the given $routeValues and throw an exception, if it can't be resolved.
  *
  * @param array $routeValues
  * @return void
  * @throws \TYPO3\FLOW3\Mvc\Routing\Exception\InvalidControllerException
  */
 protected function throwExceptionIfTargetControllerDoesNotExist(array $routeValues)
 {
     $packageKey = isset($routeValues['@package']) ? $routeValues['@package'] : '';
     $subPackageKey = isset($routeValues['@subpackage']) ? $routeValues['@subpackage'] : '';
     $controllerName = isset($routeValues['@controller']) ? $routeValues['@controller'] : '';
     $controllerObjectName = $this->router->getControllerObjectName($packageKey, $subPackageKey, $controllerName);
     if ($controllerObjectName === NULL) {
         throw new Exception\InvalidControllerException('No controller object was found for package "' . $packageKey . '", subpackage "' . $subPackageKey . '", controller "' . $controllerName . '" in route "' . $this->getName() . '".', 1301650951);
     }
 }