[BUGFIX] Fix charset inconsistency in Fluid tests
authorHelmut Hummel <helmut.hummel@typo3.org>
Sun, 11 Nov 2012 18:13:11 +0000 (19:13 +0100)
committerHelmut Hummel <helmut.hummel@typo3.org>
Sun, 18 Nov 2012 21:34:17 +0000 (22:34 +0100)
The encoding viewHelper calls resolveDefaultCharset
which in turn tries to get the charset from the system.
This is incomplete mocking and is resolved by mocking
this method. Doing so shows up another inconsistency.

Some tests assume ISO-8859-1, some UTF-8 to be the
default charset. Fix the tests to always assume UTF-8
to be the default encoding.

In addition remove the unnecessary checks in
resolveDefaultEncoding as the system default is UTF-8

Resolves: #43075
Releases: 6.0

Change-Id: Id311e5e3621c1c105a2cd182881265b92cedfebf
Reviewed-on: http://review.typo3.org/16557
Reviewed-by: Anja Leichsenring
Tested-by: Anja Leichsenring
Reviewed-by: Helmut Hummel
Tested-by: Helmut Hummel
typo3/sysext/fluid/Classes/ViewHelpers/Format/AbstractEncodingViewHelper.php
typo3/sysext/fluid/Tests/Unit/ViewHelpers/Format/HtmlentitiesViewHelperTest.php

index f7ecd3b..c4416ec 100644 (file)
@@ -31,14 +31,7 @@ abstract class AbstractEncodingViewHelper extends \TYPO3\CMS\Fluid\Core\ViewHelp
         */
        protected function resolveDefaultEncoding() {
                if (self::$defaultEncoding === NULL) {
-                       if (TYPO3_MODE === 'BE') {
-                               self::$defaultEncoding = strtoupper($GLOBALS['TYPO3_CONF_VARS']['BE']['forceCharset']);
-                       } else {
-                               self::$defaultEncoding = strtoupper($GLOBALS['TSFE']->renderCharset);
-                       }
-                       if (self::$defaultEncoding === NULL) {
-                               self::$defaultEncoding = 'UTF-8';
-                       }
+                       self::$defaultEncoding = 'UTF-8';
                }
                return self::$defaultEncoding;
        }
index afec35a..608859f 100644 (file)
@@ -21,7 +21,8 @@ class HtmlentitiesViewHelperTest extends \TYPO3\CMS\Extbase\Tests\Unit\BaseTestC
        protected $viewHelper;
 
        public function setUp() {
-               $this->viewHelper = $this->getMock('TYPO3\\CMS\\Fluid\\ViewHelpers\\Format\\HtmlentitiesViewHelper', array('renderChildren'));
+               $this->viewHelper = $this->getMock('TYPO3\\CMS\\Fluid\\ViewHelpers\\Format\\HtmlentitiesViewHelper', array('renderChildren','resolveDefaultEncoding'));
+               $this->viewHelper->expects($this->any())->method('resolveDefaultEncoding')->will($this->returnValue('UTF-8'));
        }
 
        /**
@@ -62,7 +63,7 @@ class HtmlentitiesViewHelperTest extends \TYPO3\CMS\Extbase\Tests\Unit\BaseTestC
         * @test
         */
        public function renderDecodesSimpleString() {
-               $source = 'Some special characters: &' . chr(169) . '"\'';
+               $source = 'Some special characters: &©"\'';
                $expectedResult = 'Some special characters: &amp;&copy;&quot;\'';
                $actualResult = $this->viewHelper->render($source);
                $this->assertEquals($expectedResult, $actualResult);
@@ -72,7 +73,7 @@ class HtmlentitiesViewHelperTest extends \TYPO3\CMS\Extbase\Tests\Unit\BaseTestC
         * @test
         */
        public function renderRespectsKeepQuoteArgument() {
-               $source = 'Some special characters: &' . chr(169) . '"\'';
+               $source = 'Some special characters: &©"\'';
                $expectedResult = 'Some special characters: &amp;&copy;"\'';
                $actualResult = $this->viewHelper->render($source, TRUE);
                $this->assertEquals($expectedResult, $actualResult);