[BUGFIX] Standalone- and TemplateView must not require ucfirst file names 12/34812/26
authorMarkus Klein <klein.t3@reelworx.at>
Thu, 27 Nov 2014 14:13:18 +0000 (15:13 +0100)
committerAnja Leichsenring <aleichsenring@ab-softlab.de>
Sun, 18 Jan 2015 08:58:43 +0000 (09:58 +0100)
There's no reason to require ucfirst file names for Layouts and Partials.
This patch allows free naming of Layouts, Partials and Templates.
For best performance we really suggest to stick to UpperCamelCase though.

Change-Id: I04049e2cd248288efb97e06cac3b5d8000fd1d52
Resolves: #63367
Resolves: #58087
Resolves: #64049
Releases: master
Reviewed-on: http://review.typo3.org/34812
Reviewed-by: Alexander Opitz <opitz.alexander@googlemail.com>
Tested-by: Alexander Opitz <opitz.alexander@googlemail.com>
Reviewed-by: Andreas Fernandez <andreas.fernandez@aspedia.de>
Tested-by: Andreas Fernandez <andreas.fernandez@aspedia.de>
Reviewed-by: Anja Leichsenring <aleichsenring@ab-softlab.de>
Tested-by: Anja Leichsenring <aleichsenring@ab-softlab.de>
typo3/sysext/fluid/Classes/View/AbstractTemplateView.php
typo3/sysext/fluid/Classes/View/StandaloneView.php
typo3/sysext/fluid/Classes/View/TemplateView.php
typo3/sysext/fluid/Tests/Unit/View/AbstractTemplateViewTest.php
typo3/sysext/fluid/Tests/Unit/View/StandaloneViewTest.php
typo3/sysext/fluid/Tests/Unit/View/TemplateViewTest.php

index cb6cd9e..70e05a8 100644 (file)
@@ -283,6 +283,35 @@ abstract class AbstractTemplateView implements \TYPO3\CMS\Extbase\Mvc\View\ViewI
        }
 
        /**
+        * Ensures the given templatePath gets the file name in UpperCamelCase
+        *
+        * @param string $templatePath A file name or a relative path
+        * @return string
+        */
+       protected function ucFileNameInPath($templatePath) {
+               if (strpos($templatePath, '/') > 0) {
+                       $pathParts = explode('/', $templatePath);
+                       $index = count($pathParts) - 1;
+                       $pathParts[$index] = ucfirst($pathParts[$index]);
+
+                       $upperCasedTemplateName = implode('/', $pathParts);
+               } else {
+                       $upperCasedTemplateName = ucfirst($templatePath);
+               }
+               return $upperCasedTemplateName;
+       }
+
+       /**
+        * Wrapper method for is_file function for testing reasons
+        *
+        * @param string $filePath
+        * @return bool
+        */
+       protected function testFileExistence($filePath) {
+               return is_file($filePath);
+       }
+
+       /**
         * Returns a unique identifier for the resolved template file.
         * This identifier is based on the template path and last modification date
         *
index c219b9a..fa81773 100644 (file)
@@ -20,8 +20,17 @@ namespace TYPO3\CMS\Fluid\View;
  *                                                                        *
  * The TYPO3 project - inspiring people to share!                         *
  *                                                                        */
+use TYPO3\CMS\Core\Cache\CacheManager;
 use TYPO3\CMS\Core\Utility\GeneralUtility;
+use TYPO3\CMS\Extbase\Configuration\ConfigurationManagerInterface;
+use TYPO3\CMS\Extbase\Mvc\Controller\ControllerContext;
+use TYPO3\CMS\Extbase\Mvc\Web\Request as WebRequest;
+use TYPO3\CMS\Extbase\Mvc\Web\Routing\UriBuilder;
+use TYPO3\CMS\Extbase\Object\ObjectManager;
 use TYPO3\CMS\Extbase\Utility\ArrayUtility;
+use TYPO3\CMS\Fluid\Core\Compiler\TemplateCompiler;
+use TYPO3\CMS\Fluid\Core\Parser\TemplateParser;
+use TYPO3\CMS\Fluid\Core\Rendering\RenderingContext;
 use TYPO3\CMS\Fluid\View\Exception\InvalidTemplateResourceException;
 use TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer;
 
@@ -69,31 +78,31 @@ class StandaloneView extends AbstractTemplateView {
         * @throws \UnexpectedValueException
         */
        public function __construct(ContentObjectRenderer $contentObject = NULL) {
-               $this->objectManager = GeneralUtility::makeInstance(\TYPO3\CMS\Extbase\Object\ObjectManager::class);
-               /** @var \TYPO3\CMS\Extbase\Configuration\ConfigurationManagerInterface $configurationManager */
-               $configurationManager = $this->objectManager->get(\TYPO3\CMS\Extbase\Configuration\ConfigurationManagerInterface::class);
+               $this->objectManager = GeneralUtility::makeInstance(ObjectManager::class);
+               /** @var ConfigurationManagerInterface $configurationManager */
+               $configurationManager = $this->objectManager->get(ConfigurationManagerInterface::class);
                if ($contentObject === NULL) {
                        /** @var ContentObjectRenderer $contentObject */
-                       $contentObject = GeneralUtility::makeInstance(\TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer::class);
+                       $contentObject = GeneralUtility::makeInstance(ContentObjectRenderer::class);
                }
                $configurationManager->setContentObject($contentObject);
-               $this->templateParser = $this->objectManager->get(\TYPO3\CMS\Fluid\Core\Parser\TemplateParser::class);
-               $this->setRenderingContext($this->objectManager->get(\TYPO3\CMS\Fluid\Core\Rendering\RenderingContext::class));
-               /** @var \TYPO3\CMS\Extbase\Mvc\Web\Request $request */
-               $request = $this->objectManager->get(\TYPO3\CMS\Extbase\Mvc\Web\Request::class);
+               $this->templateParser = $this->objectManager->get(TemplateParser::class);
+               $this->setRenderingContext($this->objectManager->get(RenderingContext::class));
+               /** @var WebRequest $request */
+               $request = $this->objectManager->get(WebRequest::class);
                $request->setRequestURI(GeneralUtility::getIndpEnv('TYPO3_REQUEST_URL'));
                $request->setBaseURI(GeneralUtility::getIndpEnv('TYPO3_SITE_URL'));
-               /** @var \TYPO3\CMS\Extbase\Mvc\Web\Routing\UriBuilder $uriBuilder */
-               $uriBuilder = $this->objectManager->get(\TYPO3\CMS\Extbase\Mvc\Web\Routing\UriBuilder::class);
+               /** @var UriBuilder $uriBuilder */
+               $uriBuilder = $this->objectManager->get(UriBuilder::class);
                $uriBuilder->setRequest($request);
-               /** @var \TYPO3\CMS\Extbase\Mvc\Controller\ControllerContext $controllerContext */
-               $controllerContext = $this->objectManager->get(\TYPO3\CMS\Extbase\Mvc\Controller\ControllerContext::class);
+               /** @var ControllerContext $controllerContext */
+               $controllerContext = $this->objectManager->get(ControllerContext::class);
                $controllerContext->setRequest($request);
                $controllerContext->setUriBuilder($uriBuilder);
                $this->setControllerContext($controllerContext);
-               $this->templateCompiler = $this->objectManager->get(\TYPO3\CMS\Fluid\Core\Compiler\TemplateCompiler::class);
+               $this->templateCompiler = $this->objectManager->get(TemplateCompiler::class);
                // singleton
-               $this->templateCompiler->setTemplateCache(GeneralUtility::makeInstance(\TYPO3\CMS\Core\Cache\CacheManager::class)->getCache('fluid_template'));
+               $this->templateCompiler->setTemplateCache(GeneralUtility::makeInstance(CacheManager::class)->getCache('fluid_template'));
        }
 
        /**
@@ -120,7 +129,7 @@ class StandaloneView extends AbstractTemplateView {
        /**
         * Returns the current request object
         *
-        * @return \TYPO3\CMS\Extbase\Mvc\Web\Request
+        * @return WebRequest
         */
        public function getRequest() {
                return $this->controllerContext->getRequest();
@@ -323,7 +332,7 @@ class StandaloneView extends AbstractTemplateView {
                        throw new InvalidTemplateResourceException('No template has been specified. Use either setTemplateSource() or setTemplatePathAndFilename().', 1288085266);
                }
                if ($this->templateSource === NULL) {
-                       if (!is_file($this->templatePathAndFilename)) {
+                       if (!$this->testFileExistence($this->templatePathAndFilename)) {
                                throw new InvalidTemplateResourceException('Template could not be found at "' . $this->templatePathAndFilename . '".', 1288087061);
                        }
                        $this->templateSource = file_get_contents($this->templatePathAndFilename);
@@ -375,18 +384,7 @@ class StandaloneView extends AbstractTemplateView {
         * @throws InvalidTemplateResourceException
         */
        protected function getLayoutPathAndFilename($layoutName = 'Default') {
-               $upperCasedLayoutName = ucfirst($layoutName);
-               $possibleLayoutPaths = array();
-               $paths = ArrayUtility::sortArrayWithIntegerKeys($this->getLayoutRootPaths());
-               $paths = array_reverse($paths, TRUE);
-               foreach ($paths as $layoutRootPath) {
-                       $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);
-                       }
-               }
+               $possibleLayoutPaths = $this->buildListOfTemplateCandidates($layoutName, $this->getLayoutRootPaths(), $this->getRequest()->getFormat());
                foreach ($possibleLayoutPaths as $layoutPathAndFilename) {
                        if ($this->testFileExistence($layoutPathAndFilename)) {
                                return $layoutPathAndFilename;
@@ -397,16 +395,6 @@ class StandaloneView extends AbstractTemplateView {
        }
 
        /**
-        * Wrapper method for is_file function for testing reasons
-        *
-        * @param string $filePath
-        * @return bool
-        */
-       protected function testFileExistence($filePath) {
-               return is_file($filePath);
-       }
-
-       /**
         * Returns a unique identifier for the resolved partial file.
         * This identifier is based on the template path and last modification date
         *
@@ -445,18 +433,7 @@ class StandaloneView extends AbstractTemplateView {
         * @throws InvalidTemplateResourceException
         */
        protected function getPartialPathAndFilename($partialName) {
-               $upperCasedPartialName = ucfirst($partialName);
-               $paths = ArrayUtility::sortArrayWithIntegerKeys($this->getPartialRootPaths());
-               $paths = array_reverse($paths, TRUE);
-               $possiblePartialPaths = array();
-               foreach ($paths as $partialRootPath) {
-                       $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);
-                       }
-               }
+               $possiblePartialPaths = $this->buildListOfTemplateCandidates($partialName, $this->getPartialRootPaths(), $this->getRequest()->getFormat());
                foreach ($possiblePartialPaths as $partialPathAndFilename) {
                        if ($this->testFileExistence($partialPathAndFilename)) {
                                return $partialPathAndFilename;
@@ -466,6 +443,30 @@ class StandaloneView extends AbstractTemplateView {
        }
 
        /**
+        * Builds a list of possible candidates for a given template name
+        *
+        * @param string $templateName Name of the template to search for
+        * @param array $paths Paths to search in
+        * @param string $format The file format to use. e.g 'html' or 'txt'
+        * @return array Array of paths to search for the template file
+        */
+       protected function buildListOfTemplateCandidates($templateName, array $paths, $format) {
+               $upperCasedTemplateName = $this->ucFileNameInPath($templateName);
+               $possibleTemplatePaths = array();
+               $paths = ArrayUtility::sortArrayWithIntegerKeys($paths);
+               $paths = array_reverse($paths, TRUE);
+               foreach ($paths as $layoutRootPath) {
+                       $possibleTemplatePaths[] = $this->resolveFileNamePath($layoutRootPath . '/' . $upperCasedTemplateName . '.' . $format);
+                       $possibleTemplatePaths[] = $this->resolveFileNamePath($layoutRootPath . '/' . $upperCasedTemplateName);
+                       if ($upperCasedTemplateName !== $templateName) {
+                               $possibleTemplatePaths[] = $this->resolveFileNamePath($layoutRootPath . '/' . $templateName . '.' . $format);
+                               $possibleTemplatePaths[] = $this->resolveFileNamePath($layoutRootPath . '/' . $templateName);
+                       }
+               }
+               return $possibleTemplatePaths;
+       }
+
+       /**
         * Returns a unique identifier for the given file in the format
         * Standalone_<prefix>_<SHA1>
         * The SH1 hash is a checksum that is based on the file path and last modification date
@@ -481,4 +482,14 @@ class StandaloneView extends AbstractTemplateView {
                return $templateIdentifier;
        }
 
+       /**
+        * Wrapper method to make the static call to GeneralUtility mockable in tests
+        *
+        * @param string $pathAndFilename
+        * @return string absolute pathAndFilename
+        */
+       protected function resolveFileNamePath($pathAndFilename) {
+               return GeneralUtility::getFileAbsFileName(GeneralUtility::fixWindowsFilePath($pathAndFilename), FALSE);
+       }
+
 }
index 408e4be..fd41830 100644 (file)
@@ -14,7 +14,9 @@ namespace TYPO3\CMS\Fluid\View;
 use TYPO3\CMS\Core\Utility\ExtensionManagementUtility;
 use TYPO3\CMS\Core\Utility\GeneralUtility;
 use TYPO3\CMS\Extbase\Mvc\Controller\ControllerContext;
+use TYPO3\CMS\Extbase\Object\ObjectManager;
 use TYPO3\CMS\Fluid\Compatibility\TemplateParserBuilder;
+use TYPO3\CMS\Fluid\Core\Rendering\RenderingContextInterface;
 use TYPO3\CMS\Fluid\Fluid;
 
 /**
@@ -133,8 +135,8 @@ class TemplateView extends AbstractTemplateView {
         */
        public function __construct() {
                $this->templateParser = TemplateParserBuilder::build();
-               $this->objectManager = GeneralUtility::makeInstance(\TYPO3\CMS\Extbase\Object\ObjectManager::class);
-               $this->setRenderingContext($this->objectManager->get(\TYPO3\CMS\Fluid\Core\Rendering\RenderingContextInterface::class));
+               $this->objectManager = GeneralUtility::makeInstance(ObjectManager::class);
+               $this->setRenderingContext($this->objectManager->get(RenderingContextInterface::class));
        }
 
        /**
@@ -329,23 +331,22 @@ class TemplateView extends AbstractTemplateView {
         */
        protected function getTemplatePathAndFilename($actionName = NULL) {
                if ($this->templatePathAndFilename !== NULL) {
-                       return $this->templatePathAndFilename;
+                       return $this->resolveFileNamePath($this->templatePathAndFilename);
                }
                if ($actionName === NULL) {
                        /** @var $actionRequest \TYPO3\CMS\Extbase\Mvc\Request */
                        $actionRequest = $this->controllerContext->getRequest();
                        $actionName = $actionRequest->getControllerActionName();
                }
-               $actionName = ucfirst($actionName);
 
                $paths = $this->expandGenericPathPattern($this->templatePathAndFilenamePattern, FALSE, FALSE);
-               foreach ($paths as &$templatePathAndFilename) {
-                       $templatePathAndFilename = $this->resolveFileNamePath(str_replace('@action', $actionName, $templatePathAndFilename));
-                       if (is_file($templatePathAndFilename)) {
+               $possibleFileNames = $this->buildListOfTemplateCandidates($actionName, $paths, '@action');
+               foreach ($possibleFileNames as $templatePathAndFilename) {
+                       if ($this->testFileExistence($templatePathAndFilename)) {
                                return $templatePathAndFilename;
                        }
                }
-               throw new Exception\InvalidTemplateResourceException('Template could not be loaded. I tried "' . implode('", "', $paths) . '"', 1225709595);
+               throw new Exception\InvalidTemplateResourceException('Template could not be loaded. I tried "' . implode('", "', $possibleFileNames) . '"', 1225709595);
        }
 
        /**
@@ -396,17 +397,16 @@ class TemplateView extends AbstractTemplateView {
         */
        protected function getLayoutPathAndFilename($layoutName = 'Default') {
                if ($this->layoutPathAndFilename !== NULL) {
-                       return $this->layoutPathAndFilename;
+                       return $this->resolveFileNamePath($this->layoutPathAndFilename);
                }
                $paths = $this->expandGenericPathPattern($this->layoutPathAndFilenamePattern, TRUE, TRUE);
-               $layoutName = ucfirst($layoutName);
-               foreach ($paths as &$layoutPathAndFilename) {
-                       $layoutPathAndFilename = $this->resolveFileNamePath(str_replace('@layout', $layoutName, $layoutPathAndFilename));
-                       if (is_file($layoutPathAndFilename)) {
+               $possibleFileNames = $this->buildListOfTemplateCandidates($layoutName, $paths, '@layout');
+               foreach ($possibleFileNames as $layoutPathAndFilename) {
+                       if ($this->testFileExistence($layoutPathAndFilename)) {
                                return $layoutPathAndFilename;
                        }
                }
-               throw new Exception\InvalidTemplateResourceException('The template files "' . implode('", "', $paths) . '" could not be loaded.', 1225709596);
+               throw new Exception\InvalidTemplateResourceException('The layout files "' . implode('", "', $possibleFileNames) . '" could not be loaded.', 1225709596);
        }
 
        /**
@@ -447,13 +447,33 @@ class TemplateView extends AbstractTemplateView {
         */
        protected function getPartialPathAndFilename($partialName) {
                $paths = $this->expandGenericPathPattern($this->partialPathAndFilenamePattern, TRUE, TRUE);
-               foreach ($paths as &$partialPathAndFilename) {
-                       $partialPathAndFilename = $this->resolveFileNamePath(str_replace('@partial', $partialName, $partialPathAndFilename));
-                       if (is_file($partialPathAndFilename)) {
+               $possibleFileNames = $this->buildListOfTemplateCandidates($partialName, $paths, '@partial');
+               foreach ($possibleFileNames as $partialPathAndFilename) {
+                       if ($this->testFileExistence($partialPathAndFilename)) {
                                return $partialPathAndFilename;
                        }
                }
-               throw new Exception\InvalidTemplateResourceException('The template files "' . implode('", "', $paths) . '" could not be loaded.', 1225709597);
+               throw new Exception\InvalidTemplateResourceException('The partial files "' . implode('", "', $possibleFileNames) . '" could not be loaded.', 1225709597);
+       }
+
+       /**
+        * Builds a list of possible candidates for a given template name
+        *
+        * @param string $templateName
+        * @param array $paths Paths to search in
+        * @param string $marker Marker to replace in the $templateName
+        * @return array Array of paths to search for the template file
+        */
+       protected function buildListOfTemplateCandidates($templateName, $paths, $marker) {
+               $upperCasedTemplateName = $this->ucFileNameInPath($templateName);
+               $possibleFileNames = array();
+               foreach ($paths as $partialPathAndFilename) {
+                       $possibleFileNames[] = $this->resolveFileNamePath(str_replace($marker, $upperCasedTemplateName, $partialPathAndFilename));
+                       if ($templateName !== $upperCasedTemplateName) {
+                               $possibleFileNames[] = $this->resolveFileNamePath(str_replace($marker, $templateName, $partialPathAndFilename));
+                       }
+               }
+               return $possibleFileNames;
        }
 
        /**
@@ -608,7 +628,7 @@ class TemplateView extends AbstractTemplateView {
         * @return string absolute pathAndFilename
         */
        protected function resolveFileNamePath($pathAndFilename) {
-               return GeneralUtility::getFileAbsFileName($pathAndFilename);
+               return GeneralUtility::getFileAbsFileName(GeneralUtility::fixWindowsFilePath($pathAndFilename), TRUE);
        }
 
 }
index d0063ff..acfdaa3 100644 (file)
@@ -11,28 +11,35 @@ namespace TYPO3\CMS\Fluid\Tests\Unit\View;
  * The TYPO3 project - inspiring people to share!                         *
  *                                                                        */
 
+use TYPO3\CMS\Core\Tests\AccessibleObjectInterface;
+use TYPO3\CMS\Core\Tests\UnitTestCase;
+use TYPO3\CMS\Fluid\Core\Rendering\RenderingContext;
+use TYPO3\CMS\Fluid\Core\ViewHelper\TemplateVariableContainer;
+use TYPO3\CMS\Fluid\Core\ViewHelper\ViewHelperVariableContainer;
+use TYPO3\CMS\Fluid\View\AbstractTemplateView;
+
 /**
  * Test case
  */
-class AbstractTemplateViewTest extends \TYPO3\CMS\Core\Tests\UnitTestCase {
+class AbstractTemplateViewTest extends UnitTestCase {
 
        /**
-        * @var \TYPO3\CMS\Fluid\View\AbstractTemplateView
+        * @var AbstractTemplateView|AccessibleObjectInterface
         */
        protected $view;
 
        /**
-        * @var \TYPO3\CMS\Fluid\Core\Rendering\RenderingContext
+        * @var RenderingContext|\PHPUnit_Framework_MockObject_MockObject
         */
        protected $renderingContext;
 
        /**
-        * @var \TYPO3\CMS\Fluid\Core\ViewHelper\ViewHelperVariableContainer
+        * @var ViewHelperVariableContainer|\PHPUnit_Framework_MockObject_MockObject
         */
        protected $viewHelperVariableContainer;
 
        /**
-        * @var \TYPO3\CMS\Fluid\Core\ViewHelper\TemplateVariableContainer
+        * @var TemplateVariableContainer|\PHPUnit_Framework_MockObject_MockObject
         */
        protected $templateVariableContainer;
 
@@ -42,12 +49,12 @@ class AbstractTemplateViewTest extends \TYPO3\CMS\Core\Tests\UnitTestCase {
         * @return void
         */
        public function setUp() {
-               $this->templateVariableContainer = $this->getMock(\TYPO3\CMS\Fluid\Core\ViewHelper\TemplateVariableContainer::class, array('exists', 'remove', 'add'));
-               $this->viewHelperVariableContainer = $this->getMock(\TYPO3\CMS\Fluid\Core\ViewHelper\ViewHelperVariableContainer::class, array('setView'));
-               $this->renderingContext = $this->getMock(\TYPO3\CMS\Fluid\Core\Rendering\RenderingContext::class, array('getViewHelperVariableContainer', 'getTemplateVariableContainer'));
+               $this->templateVariableContainer = $this->getMock(TemplateVariableContainer::class, array('exists', 'remove', 'add'));
+               $this->viewHelperVariableContainer = $this->getMock(ViewHelperVariableContainer::class, array('setView'));
+               $this->renderingContext = $this->getMock(RenderingContext::class, array('getViewHelperVariableContainer', 'getTemplateVariableContainer'));
                $this->renderingContext->expects($this->any())->method('getViewHelperVariableContainer')->will($this->returnValue($this->viewHelperVariableContainer));
                $this->renderingContext->expects($this->any())->method('getTemplateVariableContainer')->will($this->returnValue($this->templateVariableContainer));
-               $this->view = $this->getMock(\TYPO3\CMS\Fluid\View\AbstractTemplateView::class, array('getTemplateSource', 'getLayoutSource', 'getPartialSource', 'canRender', 'getTemplateIdentifier', 'getLayoutIdentifier', 'getPartialIdentifier'));
+               $this->view = $this->getAccessibleMock(AbstractTemplateView::class, array('getTemplateSource', 'getLayoutSource', 'getPartialSource', 'canRender', 'getTemplateIdentifier', 'getLayoutIdentifier', 'getPartialIdentifier'));
                $this->view->setRenderingContext($this->renderingContext);
        }
 
@@ -119,4 +126,26 @@ class AbstractTemplateViewTest extends \TYPO3\CMS\Core\Tests\UnitTestCase {
                $this->view->assignMultiple(array('foo' => 'FooValueOverridden', 'bar' => 'BarValue'));
        }
 
+       /**
+        * @return array
+        */
+       public function ucFileNameInPathProperlyUpperCasesFileNamesDataProvider() {
+               return [
+                       'keeps ucfirst' => ['LayoutPath', 'LayoutPath'],
+                       'creates ucfirst' => ['layoutPath', 'LayoutPath'],
+                       'ucfirst on file name only' => ['some/path/layout', 'some/path/Layout'],
+                       'keeps ucfirst on file name' => ['some/Path/Layout', 'some/Path/Layout'],
+               ];
+       }
+
+       /**
+        * @param string $path
+        * @param string $expected
+        * @dataProvider ucFileNameInPathProperlyUpperCasesFileNamesDataProvider
+        * @test
+        */
+       public function ucFileNameInPathProperlyUpperCasesFileNames($path, $expected) {
+               $this->assertSame($expected, $this->view->_call('ucFileNameInPath', $path));
+       }
+
 }
index 75946cd..5e566e5 100644 (file)
@@ -248,6 +248,7 @@ class StandaloneViewTest extends UnitTestCase {
                $templatePathAndFilename = __DIR__ . '/Fixtures/StandaloneViewFixture.html';
                $expectedResult = file_get_contents($templatePathAndFilename);
                $this->view->setTemplatePathAndFilename($templatePathAndFilename);
+               $this->view->expects($this->once())->method('testFileExistence')->with($templatePathAndFilename)->will($this->returnValue(TRUE));
                $this->mockTemplateParser->expects($this->once())->method('parse')->with($expectedResult);
                $this->view->render();
        }
@@ -518,10 +519,10 @@ class StandaloneViewTest extends UnitTestCase {
        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'));
+               $this->view->expects($this->at(0))->method('testFileExistence')->with(PATH_site . 'some/Default/Directory/LayoutName.html')->willReturn(FALSE);
+               $this->view->expects($this->at(1))->method('testFileExistence')->with(PATH_site . 'some/Default/Directory/LayoutName')->willReturn(FALSE);
+               $this->view->expects($this->at(2))->method('testFileExistence')->with(PATH_site . 'some/Default/Directory/layoutName.html')->willReturn(TRUE);
+               $this->assertSame(PATH_site . 'some/Default/Directory/layoutName.html', $this->view->_call('getLayoutPathAndFilename', 'layoutName'));
        }
 
        /**
@@ -530,8 +531,8 @@ class StandaloneViewTest extends UnitTestCase {
        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'));
+               $this->view->expects($this->at(0))->method('testFileExistence')->with(PATH_site . 'some/Default/Directory/LayoutName.html')->willReturn(TRUE);
+               $this->assertSame(PATH_site . 'some/Default/Directory/LayoutName.html', $this->view->_call('getLayoutPathAndFilename', 'layoutName'));
        }
 
        /**
@@ -543,8 +544,8 @@ class StandaloneViewTest extends UnitTestCase {
                        'specific' => 'specific/Layouts',
                ));
                $this->mockRequest->expects($this->any())->method('getFormat')->will($this->returnValue('html'));
-               $this->view->expects($this->once())->method('testFileExistence')->with('specific/Layouts/Default.html')->will($this->returnValue(TRUE));
-               $this->assertEquals('specific/Layouts/Default.html', $this->view->_call('getLayoutPathAndFilename'));
+               $this->view->expects($this->once())->method('testFileExistence')->with(PATH_site . 'specific/Layouts/Default.html')->will($this->returnValue(TRUE));
+               $this->assertEquals(PATH_site . 'specific/Layouts/Default.html', $this->view->_call('getLayoutPathAndFilename'));
        }
 
        /**
@@ -556,8 +557,8 @@ class StandaloneViewTest extends UnitTestCase {
                        'specific' => 'specific/Layouts',
                ));
                $this->mockRequest->expects($this->any())->method('getFormat')->will($this->returnValue('html'));
-               $this->view->expects($this->at(2))->method('testFileExistence')->with('some/Default/Directory/Default.html')->will($this->returnValue(TRUE));
-               $this->assertEquals('some/Default/Directory/Default.html', $this->view->_call('getLayoutPathAndFilename'));
+               $this->view->expects($this->at(2))->method('testFileExistence')->with(PATH_site . 'some/Default/Directory/Default.html')->will($this->returnValue(TRUE));
+               $this->assertEquals(PATH_site . 'some/Default/Directory/Default.html', $this->view->_call('getLayoutPathAndFilename'));
        }
 
        /**
@@ -570,8 +571,8 @@ class StandaloneViewTest extends UnitTestCase {
                        '17' => 'specific/Layouts',
                ));
                $this->mockRequest->expects($this->any())->method('getFormat')->will($this->returnValue('html'));
-               $this->view->expects($this->at(2))->method('testFileExistence')->with('specific/Layouts/Default.html')->will($this->returnValue(TRUE));
-               $this->assertEquals('specific/Layouts/Default.html', $this->view->_call('getLayoutPathAndFilename'));
+               $this->view->expects($this->at(2))->method('testFileExistence')->with(PATH_site . 'specific/Layouts/Default.html')->will($this->returnValue(TRUE));
+               $this->assertEquals(PATH_site . 'specific/Layouts/Default.html', $this->view->_call('getLayoutPathAndFilename'));
        }
 
        /**
@@ -584,8 +585,8 @@ class StandaloneViewTest extends UnitTestCase {
                        '17' => 'specific/Layouts',
                ));
                $this->mockRequest->expects($this->any())->method('getFormat')->will($this->returnValue('html'));
-               $this->view->expects($this->at(4))->method('testFileExistence')->with('some/Default/Directory/Default.html')->will($this->returnValue(TRUE));
-               $this->assertEquals('some/Default/Directory/Default.html', $this->view->_call('getLayoutPathAndFilename'));
+               $this->view->expects($this->at(4))->method('testFileExistence')->with(PATH_site . 'some/Default/Directory/Default.html')->will($this->returnValue(TRUE));
+               $this->assertEquals(PATH_site . 'some/Default/Directory/Default.html', $this->view->_call('getLayoutPathAndFilename'));
        }
 
        /**
@@ -601,7 +602,6 @@ class StandaloneViewTest extends UnitTestCase {
                ));
                $this->view->expects($this->any())->method('testFileExistence')->will($this->returnValue(FALSE));
                $this->view->_call('getLayoutPathAndFilename');
-
        }
 
        /**
@@ -610,10 +610,10 @@ class StandaloneViewTest extends UnitTestCase {
        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'));
+               $this->view->expects($this->at(0))->method('testFileExistence')->with(PATH_site . 'some/Default/Directory/PartialName.html')->willReturn(FALSE);
+               $this->view->expects($this->at(1))->method('testFileExistence')->with(PATH_site . 'some/Default/Directory/PartialName')->willReturn(FALSE);
+               $this->view->expects($this->at(2))->method('testFileExistence')->with(PATH_site . 'some/Default/Directory/partialName.html')->willReturn(TRUE);
+               $this->assertSame(PATH_site . 'some/Default/Directory/partialName.html', $this->view->_call('getPartialPathAndFilename', 'partialName'));
        }
 
        /**
@@ -622,8 +622,8 @@ class StandaloneViewTest extends UnitTestCase {
        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'));
+               $this->view->expects($this->at(0))->method('testFileExistence')->with(PATH_site . 'some/Default/Directory/PartialName.html')->willReturn(TRUE);
+               $this->assertSame(PATH_site . 'some/Default/Directory/PartialName.html', $this->view->_call('getPartialPathAndFilename', 'partialName'));
        }
 
        /**
@@ -635,8 +635,8 @@ class StandaloneViewTest extends UnitTestCase {
                        'specific' => 'specific/Partials',
                ));
                $this->mockRequest->expects($this->any())->method('getFormat')->will($this->returnValue('html'));
-               $this->view->expects($this->once())->method('testFileExistence')->with('specific/Partials/Partial.html')->will($this->returnValue(TRUE));
-               $this->assertEquals('specific/Partials/Partial.html', $this->view->_call('getPartialPathAndFilename', 'Partial'));
+               $this->view->expects($this->once())->method('testFileExistence')->with(PATH_site . 'specific/Partials/Partial.html')->will($this->returnValue(TRUE));
+               $this->assertEquals(PATH_site . 'specific/Partials/Partial.html', $this->view->_call('getPartialPathAndFilename', 'Partial'));
        }
 
        /**
@@ -648,8 +648,8 @@ class StandaloneViewTest extends UnitTestCase {
                        'specific' => 'specific/Partials',
                ));
                $this->mockRequest->expects($this->any())->method('getFormat')->will($this->returnValue('html'));
-               $this->view->expects($this->at(2))->method('testFileExistence')->with('some/Default/Directory/Partial.html')->will($this->returnValue(TRUE));
-               $this->assertEquals('some/Default/Directory/Partial.html', $this->view->_call('getPartialPathAndFilename', 'Partial'));
+               $this->view->expects($this->at(2))->method('testFileExistence')->with(PATH_site . 'some/Default/Directory/Partial.html')->will($this->returnValue(TRUE));
+               $this->assertEquals(PATH_site . 'some/Default/Directory/Partial.html', $this->view->_call('getPartialPathAndFilename', 'Partial'));
        }
 
        /**
@@ -662,8 +662,8 @@ class StandaloneViewTest extends UnitTestCase {
                        '17' => 'specific/Partials',
                ));
                $this->mockRequest->expects($this->any())->method('getFormat')->will($this->returnValue('html'));
-               $this->view->expects($this->at(2))->method('testFileExistence')->with('specific/Partials/Partial.html')->will($this->returnValue(TRUE));
-               $this->assertEquals('specific/Partials/Partial.html', $this->view->_call('getPartialPathAndFilename', 'Partial'));
+               $this->view->expects($this->at(2))->method('testFileExistence')->with(PATH_site . 'specific/Partials/Partial.html')->will($this->returnValue(TRUE));
+               $this->assertEquals(PATH_site . 'specific/Partials/Partial.html', $this->view->_call('getPartialPathAndFilename', 'Partial'));
        }
 
        /**
@@ -676,8 +676,8 @@ class StandaloneViewTest extends UnitTestCase {
                        '17' => 'specific/Partials',
                ));
                $this->mockRequest->expects($this->any())->method('getFormat')->will($this->returnValue('html'));
-               $this->view->expects($this->at(4))->method('testFileExistence')->with('some/Default/Directory/Partial.html')->will($this->returnValue(TRUE));
-               $this->assertEquals('some/Default/Directory/Partial.html', $this->view->_call('getPartialPathAndFilename', 'Partial'));
+               $this->view->expects($this->at(4))->method('testFileExistence')->with(PATH_site . 'some/Default/Directory/Partial.html')->will($this->returnValue(TRUE));
+               $this->assertEquals(PATH_site . 'some/Default/Directory/Partial.html', $this->view->_call('getPartialPathAndFilename', 'Partial'));
        }
 
        /**
@@ -705,13 +705,13 @@ class StandaloneViewTest extends UnitTestCase {
                        '17' => 'specific/Partials',
                ));
                $this->mockRequest->expects($this->any())->method('getFormat')->will($this->returnValue('html'));
-               $this->view->expects($this->at(0))->method('testFileExistence')->with('evenMore/Specific/Partials/Partial.html')->will($this->returnValue(FALSE));
-               $this->view->expects($this->at(1))->method('testFileExistence')->with('evenMore/Specific/Partials/Partial')->will($this->returnValue(FALSE));
-               $this->view->expects($this->at(2))->method('testFileExistence')->with('specific/Partials/Partial.html')->will($this->returnValue(FALSE));
-               $this->view->expects($this->at(3))->method('testFileExistence')->with('specific/Partials/Partial')->will($this->returnValue(FALSE));
-               $this->view->expects($this->at(4))->method('testFileExistence')->with('some/Default/Directory/Partial.html')->will($this->returnValue(FALSE));
-               $this->view->expects($this->at(5))->method('testFileExistence')->with('some/Default/Directory/Partial')->will($this->returnValue(TRUE));
-               $this->assertEquals('some/Default/Directory/Partial', $this->view->_call('getPartialPathAndFilename', 'Partial'));
+               $this->view->expects($this->at(0))->method('testFileExistence')->with(PATH_site . 'evenMore/Specific/Partials/Partial.html')->will($this->returnValue(FALSE));
+               $this->view->expects($this->at(1))->method('testFileExistence')->with(PATH_site . 'evenMore/Specific/Partials/Partial')->will($this->returnValue(FALSE));
+               $this->view->expects($this->at(2))->method('testFileExistence')->with(PATH_site . 'specific/Partials/Partial.html')->will($this->returnValue(FALSE));
+               $this->view->expects($this->at(3))->method('testFileExistence')->with(PATH_site . 'specific/Partials/Partial')->will($this->returnValue(FALSE));
+               $this->view->expects($this->at(4))->method('testFileExistence')->with(PATH_site . 'some/Default/Directory/Partial.html')->will($this->returnValue(FALSE));
+               $this->view->expects($this->at(5))->method('testFileExistence')->with(PATH_site . 'some/Default/Directory/Partial')->will($this->returnValue(TRUE));
+               $this->assertEquals(PATH_site . 'some/Default/Directory/Partial', $this->view->_call('getPartialPathAndFilename', 'Partial'));
        }
 
        /**
@@ -724,13 +724,13 @@ class StandaloneViewTest extends UnitTestCase {
                        '17' => 'specific/Layouts',
                ));
                $this->mockRequest->expects($this->any())->method('getFormat')->will($this->returnValue('html'));
-               $this->view->expects($this->at(0))->method('testFileExistence')->with('evenMore/Specific/Layouts/Default.html')->will($this->returnValue(FALSE));
-               $this->view->expects($this->at(1))->method('testFileExistence')->with('evenMore/Specific/Layouts/Default')->will($this->returnValue(FALSE));
-               $this->view->expects($this->at(2))->method('testFileExistence')->with('specific/Layouts/Default.html')->will($this->returnValue(FALSE));
-               $this->view->expects($this->at(3))->method('testFileExistence')->with('specific/Layouts/Default')->will($this->returnValue(FALSE));
-               $this->view->expects($this->at(4))->method('testFileExistence')->with('some/Default/Directory/Default.html')->will($this->returnValue(FALSE));
-               $this->view->expects($this->at(5))->method('testFileExistence')->with('some/Default/Directory/Default')->will($this->returnValue(TRUE));
-               $this->assertEquals('some/Default/Directory/Default', $this->view->_call('getLayoutPathAndFilename'));
+               $this->view->expects($this->at(0))->method('testFileExistence')->with(PATH_site . 'evenMore/Specific/Layouts/Default.html')->will($this->returnValue(FALSE));
+               $this->view->expects($this->at(1))->method('testFileExistence')->with(PATH_site . 'evenMore/Specific/Layouts/Default')->will($this->returnValue(FALSE));
+               $this->view->expects($this->at(2))->method('testFileExistence')->with(PATH_site . 'specific/Layouts/Default.html')->will($this->returnValue(FALSE));
+               $this->view->expects($this->at(3))->method('testFileExistence')->with(PATH_site . 'specific/Layouts/Default')->will($this->returnValue(FALSE));
+               $this->view->expects($this->at(4))->method('testFileExistence')->with(PATH_site . 'some/Default/Directory/Default.html')->will($this->returnValue(FALSE));
+               $this->view->expects($this->at(5))->method('testFileExistence')->with(PATH_site . 'some/Default/Directory/Default')->will($this->returnValue(TRUE));
+               $this->assertEquals(PATH_site . 'some/Default/Directory/Default', $this->view->_call('getLayoutPathAndFilename'));
        }
 
        /**
@@ -743,13 +743,13 @@ class StandaloneViewTest extends UnitTestCase {
                        'verySpecific' => 'evenMore/Specific/Partials',
                ));
                $this->mockRequest->expects($this->any())->method('getFormat')->will($this->returnValue('html'));
-               $this->view->expects($this->at(0))->method('testFileExistence')->with('evenMore/Specific/Partials/Partial.html')->will($this->returnValue(FALSE));
-               $this->view->expects($this->at(1))->method('testFileExistence')->with('evenMore/Specific/Partials/Partial')->will($this->returnValue(FALSE));
-               $this->view->expects($this->at(2))->method('testFileExistence')->with('specific/Partials/Partial.html')->will($this->returnValue(FALSE));
-               $this->view->expects($this->at(3))->method('testFileExistence')->with('specific/Partials/Partial')->will($this->returnValue(FALSE));
-               $this->view->expects($this->at(4))->method('testFileExistence')->with('some/Default/Directory/Partial.html')->will($this->returnValue(FALSE));
-               $this->view->expects($this->at(5))->method('testFileExistence')->with('some/Default/Directory/Partial')->will($this->returnValue(TRUE));
-               $this->assertEquals('some/Default/Directory/Partial', $this->view->_call('getPartialPathAndFilename', 'Partial'));
+               $this->view->expects($this->at(0))->method('testFileExistence')->with(PATH_site . 'evenMore/Specific/Partials/Partial.html')->will($this->returnValue(FALSE));
+               $this->view->expects($this->at(1))->method('testFileExistence')->with(PATH_site . 'evenMore/Specific/Partials/Partial')->will($this->returnValue(FALSE));
+               $this->view->expects($this->at(2))->method('testFileExistence')->with(PATH_site . 'specific/Partials/Partial.html')->will($this->returnValue(FALSE));
+               $this->view->expects($this->at(3))->method('testFileExistence')->with(PATH_site . 'specific/Partials/Partial')->will($this->returnValue(FALSE));
+               $this->view->expects($this->at(4))->method('testFileExistence')->with(PATH_site . 'some/Default/Directory/Partial.html')->will($this->returnValue(FALSE));
+               $this->view->expects($this->at(5))->method('testFileExistence')->with(PATH_site . 'some/Default/Directory/Partial')->will($this->returnValue(TRUE));
+               $this->assertEquals(PATH_site . 'some/Default/Directory/Partial', $this->view->_call('getPartialPathAndFilename', 'Partial'));
        }
 
        /**
@@ -762,13 +762,13 @@ class StandaloneViewTest extends UnitTestCase {
                        'verySpecific' => 'evenMore/Specific/Layout',
                ));
                $this->mockRequest->expects($this->any())->method('getFormat')->will($this->returnValue('html'));
-               $this->view->expects($this->at(0))->method('testFileExistence')->with('evenMore/Specific/Layout/Default.html')->will($this->returnValue(FALSE));
-               $this->view->expects($this->at(1))->method('testFileExistence')->with('evenMore/Specific/Layout/Default')->will($this->returnValue(FALSE));
-               $this->view->expects($this->at(2))->method('testFileExistence')->with('specific/Layout/Default.html')->will($this->returnValue(FALSE));
-               $this->view->expects($this->at(3))->method('testFileExistence')->with('specific/Layout/Default')->will($this->returnValue(FALSE));
-               $this->view->expects($this->at(4))->method('testFileExistence')->with('some/Default/Directory/Default.html')->will($this->returnValue(FALSE));
-               $this->view->expects($this->at(5))->method('testFileExistence')->with('some/Default/Directory/Default')->will($this->returnValue(TRUE));
-               $this->assertEquals('some/Default/Directory/Default', $this->view->_call('getLayoutPathAndFilename'));
+               $this->view->expects($this->at(0))->method('testFileExistence')->with(PATH_site . 'evenMore/Specific/Layout/Default.html')->will($this->returnValue(FALSE));
+               $this->view->expects($this->at(1))->method('testFileExistence')->with(PATH_site . 'evenMore/Specific/Layout/Default')->will($this->returnValue(FALSE));
+               $this->view->expects($this->at(2))->method('testFileExistence')->with(PATH_site . 'specific/Layout/Default.html')->will($this->returnValue(FALSE));
+               $this->view->expects($this->at(3))->method('testFileExistence')->with(PATH_site . 'specific/Layout/Default')->will($this->returnValue(FALSE));
+               $this->view->expects($this->at(4))->method('testFileExistence')->with(PATH_site . 'some/Default/Directory/Default.html')->will($this->returnValue(FALSE));
+               $this->view->expects($this->at(5))->method('testFileExistence')->with(PATH_site . 'some/Default/Directory/Default')->will($this->returnValue(TRUE));
+               $this->assertEquals(PATH_site . 'some/Default/Directory/Default', $this->view->_call('getLayoutPathAndFilename'));
        }
 
 }
index 7dffdd3..f1a24e3 100644 (file)
@@ -15,13 +15,27 @@ include_once(__DIR__ . '/Fixtures/TransparentSyntaxTreeNode.php');
 include_once(__DIR__ . '/Fixtures/TemplateViewFixture.php');
 
 use org\bovigo\vfs\vfsStreamWrapper;
+use TYPO3\CMS\Core\Cache\CacheManager;
+use TYPO3\CMS\Core\Cache\Frontend\PhpFrontend;
+use TYPO3\CMS\Core\Tests\AccessibleObjectInterface;
+use TYPO3\CMS\Core\Tests\UnitTestCase;
 use TYPO3\CMS\Core\Utility\ExtensionManagementUtility;
+use TYPO3\CMS\Extbase\Mvc\Controller\ControllerContext;
+use TYPO3\CMS\Extbase\Mvc\Web\Request as WebRequest;
+use TYPO3\CMS\Extbase\Object\ObjectManager;
+use TYPO3\CMS\Fluid\Core\Compiler\TemplateCompiler;
+use TYPO3\CMS\Fluid\Core\Parser\ParsedTemplateInterface;
+use TYPO3\CMS\Fluid\Core\Parser\TemplateParser;
+use TYPO3\CMS\Fluid\Core\Rendering\RenderingContext;
+use TYPO3\CMS\Fluid\Core\ViewHelper\ViewHelperVariableContainer;
 use TYPO3\CMS\Fluid\View\TemplateView;
+use TYPO3\CMS\Core\Utility\GeneralUtility;
+use TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer;
 
 /**
  * Test case
  */
-class TemplateViewTest extends \TYPO3\CMS\Core\Tests\UnitTestCase {
+class TemplateViewTest extends UnitTestCase {
 
        /**
         * Test for #42123
@@ -30,7 +44,7 @@ class TemplateViewTest extends \TYPO3\CMS\Core\Tests\UnitTestCase {
         */
        public function expandGenericPathPatternWorksWithOldNamingSchemeOfSubPackage() {
                $mockControllerContext = $this->setupMockControllerContextForPathResolving('MyPackage', 'ViewHelpers_Widget', 'Paginate', 'html');
-               $templateView = $this->getAccessibleMock(\TYPO3\CMS\Fluid\View\TemplateView::class, array('dummy'), array(), '', FALSE);
+               $templateView = $this->getAccessibleMock(TemplateView::class, array('dummy'), array(), '', FALSE);
                $templateView->_set('controllerContext', $mockControllerContext);
                $expected = array(ExtensionManagementUtility::extPath('frontend') . 'Resources/Private/Templates/ViewHelpers/Widget/Paginate/@action.html');
                $actual = $templateView->_call('expandGenericPathPattern', '@templateRoot/@subpackage/@controller/@action.@format', FALSE, FALSE);
@@ -44,7 +58,7 @@ class TemplateViewTest extends \TYPO3\CMS\Core\Tests\UnitTestCase {
         */
        public function expandGenericPathPatternWorksWithNewNamingSchemeOfSubPackage() {
                $mockControllerContext = $this->setupMockControllerContextForPathResolving('MyPackage', 'ViewHelpers\\Widget', 'Paginate', 'html');
-               $templateView = $this->getAccessibleMock(\TYPO3\CMS\Fluid\View\TemplateView::class, array('dummy'), array(), '', FALSE);
+               $templateView = $this->getAccessibleMock(TemplateView::class, array('dummy'), array(), '', FALSE);
                $templateView->_set('controllerContext', $mockControllerContext);
                $expected = array(ExtensionManagementUtility::extPath('frontend') . 'Resources/Private/Templates/ViewHelpers/Widget/Paginate/@action.html');
                $actual = $templateView->_call('expandGenericPathPattern', '@templateRoot/@subpackage/@controller/@action.@format', FALSE, FALSE);
@@ -58,11 +72,11 @@ class TemplateViewTest extends \TYPO3\CMS\Core\Tests\UnitTestCase {
         * @param string $subPackageKey
         * @param string $controllerName
         * @param string $format
-        * @return \TYPO3\CMS\Extbase\Mvc\Controller\ControllerContext
+        * @return ControllerContext
         */
        protected function setupMockControllerContextForPathResolving($packageKey, $subPackageKey, $controllerName, $format) {
                $controllerObjectName = "TYPO3\\$packageKey\\" . ($subPackageKey != $subPackageKey . '\\' ? : '') . 'Controller\\' . $controllerName . 'Controller';
-               $mockRequest = $this->getMock(\TYPO3\CMS\Extbase\Mvc\Web\Request::class);
+               $mockRequest = $this->getMock(WebRequest::class);
                $mockRequest->expects($this->any())->method('getControllerExtensionKey')->will($this->returnValue('frontend'));
                $mockRequest->expects($this->any())->method('getControllerPackageKey')->will($this->returnValue($packageKey));
                $mockRequest->expects($this->any())->method('getControllerSubPackageKey')->will($this->returnValue($subPackageKey));
@@ -70,7 +84,7 @@ class TemplateViewTest extends \TYPO3\CMS\Core\Tests\UnitTestCase {
                $mockRequest->expects($this->any())->method('getControllerObjectName')->will($this->returnValue($controllerObjectName));
                $mockRequest->expects($this->any())->method('getFormat')->will($this->returnValue($format));
 
-               $mockControllerContext = $this->getMock(\TYPO3\CMS\Extbase\Mvc\Controller\ControllerContext::class, array('getRequest'), array(), '', FALSE);
+               $mockControllerContext = $this->getMock(ControllerContext::class, array('getRequest'), array(), '', FALSE);
                $mockControllerContext->expects($this->any())->method('getRequest')->will($this->returnValue($mockRequest));
 
                return $mockControllerContext;
@@ -491,7 +505,7 @@ class TemplateViewTest extends \TYPO3\CMS\Core\Tests\UnitTestCase {
                $mockControllerContext = $this->setupMockControllerContextForPathResolving($package, $subPackage, $controller, $format);
 
                /** @var TemplateView|\PHPUnit_Framework_MockObject_MockObject|\TYPO3\CMS\Core\Tests\AccessibleObjectInterface $templateView */
-               $templateView = $this->getAccessibleMock(\TYPO3\CMS\Fluid\View\TemplateView::class, array('dummy'), array(), '', FALSE);
+               $templateView = $this->getAccessibleMock(TemplateView::class, array('dummy'), array(), '', FALSE);
                $templateView->setControllerContext($mockControllerContext);
                if ($templateRootPath !== NULL) {
                        $templateView->setTemplateRootPath($templateRootPath);
@@ -524,7 +538,7 @@ class TemplateViewTest extends \TYPO3\CMS\Core\Tests\UnitTestCase {
        public function expandGenericPathPatternWorksWithBubblingDisabledAndFormatNotOptional() {
                $mockControllerContext = $this->setupMockControllerContextForPathResolving('MyPackage', NULL, 'My', 'html');
 
-               $templateView = $this->getAccessibleMock(\TYPO3\CMS\Fluid\View\TemplateView::class, array('getTemplateRootPaths'), array(), '', FALSE);
+               $templateView = $this->getAccessibleMock(TemplateView::class, array('getTemplateRootPaths'), array(), '', FALSE);
                $templateView->_set('controllerContext', $mockControllerContext);
                $templateView->expects($this->any())->method('getTemplateRootPaths')->will($this->returnValue(array('Resources/Private/')));
 
@@ -540,7 +554,7 @@ class TemplateViewTest extends \TYPO3\CMS\Core\Tests\UnitTestCase {
        public function expandGenericPathPatternWorksWithSubpackageAndBubblingDisabledAndFormatNotOptional() {
                $mockControllerContext = $this->setupMockControllerContextForPathResolving('MyPackage', 'MySubPackage', 'My', 'html');
 
-               $templateView = $this->getAccessibleMock(\TYPO3\CMS\Fluid\View\TemplateView::class, array('getTemplateRootPaths'), array(), '', FALSE);
+               $templateView = $this->getAccessibleMock(TemplateView::class, array('getTemplateRootPaths'), array(), '', FALSE);
                $templateView->_set('controllerContext', $mockControllerContext);
                $templateView->expects($this->any())->method('getTemplateRootPaths')->will($this->returnValue(array('Resources/Private/')));
                $actual = $templateView->_call('expandGenericPathPattern', '@templateRoot/Templates/@subpackage/@controller/@action.@format', FALSE, FALSE);
@@ -557,7 +571,7 @@ class TemplateViewTest extends \TYPO3\CMS\Core\Tests\UnitTestCase {
        public function expandGenericPathPatternWorksWithSubpackageAndBubblingDisabledAndFormatOptional() {
                $mockControllerContext = $this->setupMockControllerContextForPathResolving('MyPackage', 'MySubPackage', 'My', 'html');
 
-               $templateView = $this->getAccessibleMock(\TYPO3\CMS\Fluid\View\TemplateView::class, array('getTemplateRootPaths'), array(), '', FALSE);
+               $templateView = $this->getAccessibleMock(TemplateView::class, array('getTemplateRootPaths'), array(), '', FALSE);
                $templateView->_set('controllerContext', $mockControllerContext);
                $templateView->expects($this->any())->method('getTemplateRootPaths')->will($this->returnValue(array('Resources/Private/')));
                $actual = $templateView->_call('expandGenericPathPattern', '@templateRoot/Templates/@subpackage/@controller/@action.@format', FALSE, TRUE);
@@ -575,7 +589,7 @@ class TemplateViewTest extends \TYPO3\CMS\Core\Tests\UnitTestCase {
        public function expandGenericPathPatternWorksWithSubpackageAndBubblingEnabledAndFormatOptional() {
                $mockControllerContext = $this->setupMockControllerContextForPathResolving('MyPackage', 'MySubPackage', 'My', 'html');
 
-               $templateView = $this->getAccessibleMock(\TYPO3\CMS\Fluid\View\TemplateView::class, array('getTemplateRootPaths'), array(), '', FALSE);
+               $templateView = $this->getAccessibleMock(TemplateView::class, array('getTemplateRootPaths'), array(), '', FALSE);
                $templateView->_set('controllerContext', $mockControllerContext);
                $templateView->expects($this->any())->method('getTemplateRootPaths')->will($this->returnValue(array('Resources/Private/')));
                $actual = $templateView->_call('expandGenericPathPattern', '@templateRoot/Templates/@subpackage/@controller/@action.@format', TRUE, TRUE);
@@ -596,7 +610,7 @@ class TemplateViewTest extends \TYPO3\CMS\Core\Tests\UnitTestCase {
         */
        public function getTemplateRootPathsReturnsUserSpecifiedTemplatePaths() {
                /** @var TemplateView|\PHPUnit_Framework_MockObject_MockObject|\TYPO3\CMS\Core\Tests\AccessibleObjectInterface $templateView */
-               $templateView = $this->getAccessibleMock(\TYPO3\CMS\Fluid\View\TemplateView::class, array('dummy'), array(), '', FALSE);
+               $templateView = $this->getAccessibleMock(TemplateView::class, array('dummy'), array(), '', FALSE);
                $templateView->setTemplateRootPath('/foo/bar');
                $expected = array('/foo/bar');
                $actual = $templateView->_call('getTemplateRootPaths');
@@ -608,7 +622,7 @@ class TemplateViewTest extends \TYPO3\CMS\Core\Tests\UnitTestCase {
         */
        public function setTemplateRootPathOverrulesSetTemplateRootPaths() {
                /** @var TemplateView|\PHPUnit_Framework_MockObject_MockObject|\TYPO3\CMS\Core\Tests\AccessibleObjectInterface $templateView */
-               $templateView = $this->getAccessibleMock(\TYPO3\CMS\Fluid\View\TemplateView::class, array('dummy'), array(), '', FALSE);
+               $templateView = $this->getAccessibleMock(TemplateView::class, array('dummy'), array(), '', FALSE);
                $templateView->setTemplateRootPath('/foo/bar');
                $templateView->setTemplateRootPaths(array('/overruled/path'));
                $expected = array('/overruled/path');
@@ -621,7 +635,7 @@ class TemplateViewTest extends \TYPO3\CMS\Core\Tests\UnitTestCase {
         */
        public function getPartialRootPathsReturnsUserSpecifiedPartialPath() {
                /** @var TemplateView|\PHPUnit_Framework_MockObject_MockObject|\TYPO3\CMS\Core\Tests\AccessibleObjectInterface $templateView */
-               $templateView = $this->getAccessibleMock(\TYPO3\CMS\Fluid\View\TemplateView::class, array('dummy'), array(), '', FALSE);
+               $templateView = $this->getAccessibleMock(TemplateView::class, array('dummy'), array(), '', FALSE);
                $templateView->setPartialRootPath('/foo/bar');
                $expected = array('/foo/bar');
                $actual = $templateView->_call('getPartialRootPaths');
@@ -633,7 +647,7 @@ class TemplateViewTest extends \TYPO3\CMS\Core\Tests\UnitTestCase {
         */
        public function getLayoutRootPathsReturnsUserSpecifiedPartialPath() {
                /** @var TemplateView|\PHPUnit_Framework_MockObject_MockObject|\TYPO3\CMS\Core\Tests\AccessibleObjectInterface $templateView */
-               $templateView = $this->getAccessibleMock(\TYPO3\CMS\Fluid\View\TemplateView::class, array('dummy'), array(), '', FALSE);
+               $templateView = $this->getAccessibleMock(TemplateView::class, array('dummy'), array(), '', FALSE);
                $templateView->setLayoutRootPath('/foo/bar');
                $expected = array('/foo/bar');
                $actual = $templateView->_call('getLayoutRootPaths');
@@ -655,7 +669,7 @@ class TemplateViewTest extends \TYPO3\CMS\Core\Tests\UnitTestCase {
                );
 
                /** @var TemplateView|\PHPUnit_Framework_MockObject_MockObject|\TYPO3\CMS\Core\Tests\AccessibleObjectInterface $templateView */
-               $templateView = $this->getAccessibleMock(\TYPO3\CMS\Fluid\View\TemplateView::class, array('expandGenericPathPattern', 'resolveFileNamePath'), array(), '', FALSE);
+               $templateView = $this->getAccessibleMock(TemplateView::class, array('expandGenericPathPattern', 'resolveFileNamePath'), array(), '', FALSE);
                $templateView->expects($this->once())->method('expandGenericPathPattern')->with('@partialRoot/@subpackage/@partial.@format', TRUE, TRUE)->will($this->returnValue($paths));
                $templateView->expects($this->any())->method('resolveFileNamePath')->will($this->onConsecutiveCalls(
                        $paths[0],
@@ -684,7 +698,7 @@ class TemplateViewTest extends \TYPO3\CMS\Core\Tests\UnitTestCase {
                );
 
                /** @var TemplateView|\PHPUnit_Framework_MockObject_MockObject|\TYPO3\CMS\Core\Tests\AccessibleObjectInterface $templateView */
-               $templateView = $this->getAccessibleMock(\TYPO3\CMS\Fluid\View\TemplateView::class, array('expandGenericPathPattern', 'resolveFileNamePath'), array(), '', FALSE);
+               $templateView = $this->getAccessibleMock(TemplateView::class, array('expandGenericPathPattern', 'resolveFileNamePath'), array(), '', FALSE);
                $templateView->expects($this->once())->method('expandGenericPathPattern')->with('@templateRoot/@subpackage/@controller/@action.@format', FALSE, FALSE)->will($this->returnValue($paths));
                $templateView->expects($this->any())->method('resolveFileNamePath')->will($this->onConsecutiveCalls(
                        $paths[0],
@@ -707,10 +721,64 @@ class TemplateViewTest extends \TYPO3\CMS\Core\Tests\UnitTestCase {
                mkdir('vfs://MyTemplates');
                \file_put_contents('vfs://MyTemplates/MyCoolAction.html', 'contentsOfMyCoolAction');
 
-               $templateView = $this->getAccessibleMock(\TYPO3\CMS\Fluid\View\TemplateView::class, array('dummy'), array(), '', FALSE);
+               $templateView = $this->getAccessibleMock(TemplateView::class, array('resolveFileNamePath'), array(), '', FALSE);
+               $templateView->expects($this->any())->method('resolveFileNamePath')->willReturnArgument(0);
                $templateView->_set('templatePathAndFilename', 'vfs://MyTemplates/MyCoolAction.html');
 
                $this->assertSame('contentsOfMyCoolAction', $templateView->_call('getTemplateSource'));
        }
 
+       /**
+        * @test
+        */
+       public function getLayoutPathAndFilenameRespectsCasingOfLayoutName() {
+               $singletonInstances = GeneralUtility::getSingletonInstances();
+
+               $mockParsedTemplate = $this->getMock(ParsedTemplateInterface::class);
+               $mockTemplateParser = $this->getMock(TemplateParser::class);
+               $mockTemplateParser->expects($this->any())->method('parse')->will($this->returnValue($mockParsedTemplate));
+
+               /** @var ObjectManager|\PHPUnit_Framework_MockObject_MockObject $mockObjectManager */
+               $mockObjectManager = $this->getMock(ObjectManager::class);
+               $mockObjectManager->expects($this->any())->method('get')->will($this->returnCallback(array($this, 'objectManagerCallback')));
+
+               $mockRequest = $this->getMock(WebRequest::class);
+               $mockControllerContext = $this->getMock(ControllerContext::class);
+               $mockControllerContext->expects($this->any())->method('getRequest')->will($this->returnValue($mockRequest));
+
+               $mockViewHelperVariableContainer = $this->getMock(ViewHelperVariableContainer::class);
+               /** @var RenderingContext|\PHPUnit_Framework_MockObject_MockObject $mockRenderingContext */
+               $mockRenderingContext = $this->getMock(RenderingContext::class);
+               $mockRenderingContext->expects($this->any())->method('getControllerContext')->will($this->returnValue($mockControllerContext));
+               $mockRenderingContext->expects($this->any())->method('getViewHelperVariableContainer')->will($this->returnValue($mockViewHelperVariableContainer));
+
+               /** @var TemplateView|\PHPUnit_Framework_MockObject_MockObject|AccessibleObjectInterface $view */
+               $view = $this->getAccessibleMock(TemplateView::class, array('testFileExistence', 'buildParserConfiguration'), array(), '', FALSE);
+               $view->_set('templateParser', $mockTemplateParser);
+               $view->_set('objectManager', $mockObjectManager);
+               $view->setRenderingContext($mockRenderingContext);
+
+               $mockTemplateCompiler = $this->getMock(TemplateCompiler::class);
+               $view->_set('templateCompiler', $mockTemplateCompiler);
+               GeneralUtility::setSingletonInstance(ObjectManager::class, $mockObjectManager);
+               $mockContentObject = $this->getMock(ContentObjectRenderer::class);
+               GeneralUtility::addInstance(ContentObjectRenderer::class, $mockContentObject);
+
+               /** @var CacheManager|\PHPUnit_Framework_MockObject_MockObject $mockCacheManager */
+               $mockCacheManager = $this->getMock(CacheManager::class, array(), array(), '', FALSE);
+               $mockCache = $this->getMock(PhpFrontend::class, array(), array(), '', FALSE);
+               $mockCacheManager->expects($this->any())->method('getCache')->will($this->returnValue($mockCache));
+               GeneralUtility::setSingletonInstance(CacheManager::class, $mockCacheManager);
+
+               $mockRequest->expects($this->any())->method('getFormat')->will($this->returnValue('html'));
+               $view->setLayoutRootPaths(array('some/Default/Directory'));
+               $view->setTemplateRootPaths(array('some/Default/Directory'));
+               $view->setPartialRootPaths(array('some/Default/Directory'));
+               $view->expects($this->at(0))->method('testFileExistence')->with(PATH_site . 'some/Default/Directory/LayoutName.html')->willReturn(FALSE);
+               $view->expects($this->at(1))->method('testFileExistence')->with(PATH_site . 'some/Default/Directory/layoutName.html')->willReturn(TRUE);
+               $this->assertSame(PATH_site . 'some/Default/Directory/layoutName.html', $view->_call('getLayoutPathAndFilename', 'layoutName'));
+
+               GeneralUtility::purgeInstances();
+               GeneralUtility::resetSingletonInstances($singletonInstances);
+       }
 }