[+BUGFIX] Extbase (MVC): Using TypoScript configuration option "forceAbsoluteUrl...
authorBastian Waidelich <bastian@typo3.org>
Fri, 18 Jun 2010 15:33:23 +0000 (15:33 +0000)
committerBastian Waidelich <bastian@typo3.org>
Fri, 18 Jun 2010 15:33:23 +0000 (15:33 +0000)
typo3/sysext/extbase/Classes/MVC/Web/Routing/UriBuilder.php
typo3/sysext/extbase/Tests/MVC/Web/Routing/UriBuilder_testcase.php

index 10a5c38..0349c60 100644 (file)
@@ -482,11 +482,11 @@ class Tx_Extbase_MVC_Web_Routing_UriBuilder {
        public function buildFrontendUri() {
                $typolinkConfiguration = $this->buildTypolinkConfiguration();
 
-               $uri = $this->contentObject->typoLink_URL($typolinkConfiguration);
-               $uri = ltrim($uri, '/');
                if ($this->createAbsoluteUri === TRUE) {
-                       $uri = $this->request->getBaseURI() . $uri;
+                       $typolinkConfiguration['forceAbsoluteUrl'] = TRUE;
                }
+
+               $uri = $this->contentObject->typoLink_URL($typolinkConfiguration);
                return $uri;
        }
 
index 8eef2af..27d9184 100644 (file)
@@ -299,10 +299,10 @@ class Tx_Extbase_MVC_Web_Routing_UriBuilder_testcase extends Tx_Extbase_BaseTest
        /**
         * @test
         */
-       public function buildFrontendUriStripsLeadingSlashesFromRelativeUris() {
+       public function buildFrontendUriDoesNotStripLeadingSlashesFromRelativeUris() {
                $this->contentObject->expects($this->once())->method('typoLink_URL')->will($this->returnValue('/relative/uri'));
 
-               $expectedResult = 'relative/uri';
+               $expectedResult = '/relative/uri';
                $actualResult = $this->uriBuilder->buildFrontendUri();
 
                $this->assertSame($expectedResult, $actualResult);
@@ -312,12 +312,14 @@ class Tx_Extbase_MVC_Web_Routing_UriBuilder_testcase extends Tx_Extbase_BaseTest
         * @test
         */
        public function buildFrontendUriCreatesAbsoluteUrisIfSpecified() {
-               $this->request->expects($this->any())->method('getBaseURI')->will($this->returnValue('http://baseuri/'));
-               $this->contentObject->expects($this->once())->method('typoLink_URL')->will($this->returnValue('relative/uri'));
-               $this->uriBuilder->setCreateAbsoluteUri(TRUE);
+               $uriBuilder = $this->getMock('Tx_Extbase_MVC_Web_Routing_UriBuilder', array('buildTypolinkConfiguration'), array($this->contentObject));
+               $uriBuilder->expects($this->once())->method('buildTypolinkConfiguration')->will($this->returnValue(array('foo' => 'bar')));
+
+               $this->contentObject->expects($this->once())->method('typoLink_URL')->with(array('foo' => 'bar', 'forceAbsoluteUrl' => TRUE))->will($this->returnValue('http://baseuri/relative/uri'));
+               $uriBuilder->setCreateAbsoluteUri(TRUE);
 
                $expectedResult = 'http://baseuri/relative/uri';
-               $actualResult = $this->uriBuilder->buildFrontendUri();
+               $actualResult = $uriBuilder->buildFrontendUri();
                $this->assertSame($expectedResult, $actualResult);
        }