[BUGFIX] StandaloneView must not require ucfirst file names 20/34920/2
authorMarkus Klein <klein.t3@reelworx.at>
Thu, 27 Nov 2014 14:13:18 +0000 (15:13 +0100)
committerAnja Leichsenring <aleichsenring@ab-softlab.de>
Tue, 2 Dec 2014 15:03:28 +0000 (16:03 +0100)
Regression to #61361.
There's no reason to require ucfirst file names for Layouts and Partials.

Change-Id: I9402af9120440d9460eec5290b81acda7db0c1cc
Resolves: #63367
Releases: 6.2, master
Reviewed-on: http://review.typo3.org/34920
Reviewed-by: Alexander Opitz <opitz.alexander@googlemail.com>
Reviewed-by: Jigal van Hemert <jigal.van.hemert@typo3.org>
Tested-by: Jigal van Hemert <jigal.van.hemert@typo3.org>
Reviewed-by: Anja Leichsenring <aleichsenring@ab-softlab.de>
Tested-by: Anja Leichsenring <aleichsenring@ab-softlab.de>
typo3/sysext/fluid/Classes/View/StandaloneView.php
typo3/sysext/fluid/Tests/Unit/View/StandaloneViewTest.php

index ffeb00f..dc7a4a0 100644 (file)
@@ -375,13 +375,17 @@ class StandaloneView extends AbstractTemplateView {
         * @throws InvalidTemplateResourceException
         */
        protected function getLayoutPathAndFilename($layoutName = 'Default') {
-               $layoutName = ucfirst($layoutName);
+               $upperCasedLayoutName = ucfirst($layoutName);
                $possibleLayoutPaths = array();
                $paths = ArrayUtility::sortArrayWithIntegerKeys($this->getLayoutRootPaths());
                $paths = array_reverse($paths, TRUE);
                foreach ($paths as $layoutRootPath) {
-                       $possibleLayoutPaths[] = GeneralUtility::fixWindowsFilePath($layoutRootPath . '/' . $layoutName . '.' . $this->getRequest()->getFormat());
-                       $possibleLayoutPaths[] = GeneralUtility::fixWindowsFilePath($layoutRootPath . '/' . $layoutName);
+                       $possibleLayoutPaths[] = GeneralUtility::fixWindowsFilePath($layoutRootPath . '/' . $upperCasedLayoutName . '.' . $this->getRequest()->getFormat());
+                       $possibleLayoutPaths[] = GeneralUtility::fixWindowsFilePath($layoutRootPath . '/' . $upperCasedLayoutName);
+                       if ($upperCasedLayoutName !== $layoutName) {
+                               $possibleLayoutPaths[] = GeneralUtility::fixWindowsFilePath($layoutRootPath . '/' . $layoutName . '.' . $this->getRequest()->getFormat());
+                               $possibleLayoutPaths[] = GeneralUtility::fixWindowsFilePath($layoutRootPath . '/' . $layoutName);
+                       }
                }
                foreach ($possibleLayoutPaths as $layoutPathAndFilename) {
                        if ($this->testFileExistence($layoutPathAndFilename)) {
@@ -441,13 +445,17 @@ class StandaloneView extends AbstractTemplateView {
         * @throws InvalidTemplateResourceException
         */
        protected function getPartialPathAndFilename($partialName) {
-               $partialName = ucfirst($partialName);
+               $upperCasedPartialName = ucfirst($partialName);
                $paths = ArrayUtility::sortArrayWithIntegerKeys($this->getPartialRootPaths());
                $paths = array_reverse($paths, TRUE);
                $possiblePartialPaths = array();
                foreach ($paths as $partialRootPath) {
-                       $possiblePartialPaths[] = GeneralUtility::fixWindowsFilePath($partialRootPath . '/' . $partialName . '.' . $this->getRequest()->getFormat());
-                       $possiblePartialPaths[] = GeneralUtility::fixWindowsFilePath($partialRootPath . '/' . $partialName);
+                       $possiblePartialPaths[] = GeneralUtility::fixWindowsFilePath($partialRootPath . '/' . $upperCasedPartialName . '.' . $this->getRequest()->getFormat());
+                       $possiblePartialPaths[] = GeneralUtility::fixWindowsFilePath($partialRootPath . '/' . $upperCasedPartialName);
+                       if ($upperCasedPartialName !== $partialName) {
+                               $possiblePartialPaths[] = GeneralUtility::fixWindowsFilePath($partialRootPath . '/' . $partialName . '.' . $this->getRequest()->getFormat());
+                               $possiblePartialPaths[] = GeneralUtility::fixWindowsFilePath($partialRootPath . '/' . $partialName);
+                       }
                }
                foreach ($possiblePartialPaths as $partialPathAndFilename) {
                        if ($this->testFileExistence($partialPathAndFilename)) {
index 2b54e6f..75946cd 100644 (file)
@@ -515,6 +515,28 @@ class StandaloneViewTest extends UnitTestCase {
        /**
         * @test
         */
+       public function getLayoutPathAndFilenameRespectsCasingOfLayoutName() {
+               $this->view->setLayoutRootPaths(array('some/Default/Directory'));
+               $this->mockRequest->expects($this->any())->method('getFormat')->will($this->returnValue('html'));
+               $this->view->expects($this->at(0))->method('testFileExistence')->with('some/Default/Directory/LayoutName.html')->willReturn(FALSE);
+               $this->view->expects($this->at(1))->method('testFileExistence')->with('some/Default/Directory/LayoutName')->willReturn(FALSE);
+               $this->view->expects($this->at(2))->method('testFileExistence')->with('some/Default/Directory/layoutName.html')->willReturn(TRUE);
+               $this->assertSame('some/Default/Directory/layoutName.html', $this->view->_call('getLayoutPathAndFilename', 'layoutName'));
+       }
+
+       /**
+        * @test
+        */
+       public function getLayoutPathAndFilenameFindsUpperCasedLayoutName() {
+               $this->view->setLayoutRootPaths(array('some/Default/Directory'));
+               $this->mockRequest->expects($this->any())->method('getFormat')->will($this->returnValue('html'));
+               $this->view->expects($this->at(0))->method('testFileExistence')->with('some/Default/Directory/LayoutName.html')->willReturn(TRUE);
+               $this->assertSame('some/Default/Directory/LayoutName.html', $this->view->_call('getLayoutPathAndFilename', 'layoutName'));
+       }
+
+       /**
+        * @test
+        */
        public function getLayoutPathAndFilenameResolvesTheSpecificFile() {
                $this->view->setLayoutRootPaths(array(
                        'default' => 'some/Default/Directory',
@@ -585,6 +607,28 @@ class StandaloneViewTest extends UnitTestCase {
        /**
         * @test
         */
+       public function getPartialPathAndFilenameRespectsCasingOfPartialName() {
+               $this->view->setPartialRootPaths(array('some/Default/Directory'));
+               $this->mockRequest->expects($this->any())->method('getFormat')->will($this->returnValue('html'));
+               $this->view->expects($this->at(0))->method('testFileExistence')->with('some/Default/Directory/PartialName.html')->willReturn(FALSE);
+               $this->view->expects($this->at(1))->method('testFileExistence')->with('some/Default/Directory/PartialName')->willReturn(FALSE);
+               $this->view->expects($this->at(2))->method('testFileExistence')->with('some/Default/Directory/partialName.html')->willReturn(TRUE);
+               $this->assertSame('some/Default/Directory/partialName.html', $this->view->_call('getPartialPathAndFilename', 'partialName'));
+       }
+
+       /**
+        * @test
+        */
+       public function getPartialPathAndFilenameFindsUpperCasedPartialName() {
+               $this->view->setPartialRootPaths(array('some/Default/Directory'));
+               $this->mockRequest->expects($this->any())->method('getFormat')->will($this->returnValue('html'));
+               $this->view->expects($this->at(0))->method('testFileExistence')->with('some/Default/Directory/PartialName.html')->willReturn(TRUE);
+               $this->assertSame('some/Default/Directory/PartialName.html', $this->view->_call('getPartialPathAndFilename', 'partialName'));
+       }
+
+       /**
+        * @test
+        */
        public function getPartialPathAndFilenameResolvesTheSpecificFile() {
                $this->view->setPartialRootPaths(array(
                        'default' => 'some/Default/Directory',