2 namespace TYPO3\CMS\Fluid\Tests\Unit\ViewHelpers
;
5 * This file is part of the TYPO3 CMS project.
7 * It is free software; you can redistribute it and/or modify it under
8 * the terms of the GNU General Public License, either version 2
9 * of the License, or any later version.
11 * For the full copyright and license information, please read the
12 * LICENSE.txt file that was distributed with this source code.
14 * The TYPO3 project - inspiring people to share!
17 use TYPO3\CMS\Core\Utility\GeneralUtility
;
18 use TYPO3\CMS\Fluid\Tests\Unit\ViewHelpers\Fixtures\TranslateViewHelperFixtureForEmptyString
;
19 use TYPO3\CMS\Fluid\Tests\Unit\ViewHelpers\Fixtures\TranslateViewHelperFixtureForTranslatedString
;
20 use TYPO3\CMS\Fluid\ViewHelpers\TranslateViewHelper
;
23 * Test class for TranslateViewHelper
25 class TranslateViewHelperTest
extends ViewHelperBaseTestcase
{
28 * @var TranslateViewHelper
34 * @expectedException \TYPO3\CMS\Fluid\Core\ViewHelper\Exception\InvalidVariableException
35 * @expectedExceptionCode 1351584844
37 public function renderThrowsExceptionIfNoKeyOrIdParameterIsGiven() {
38 $this->subject
= GeneralUtility
::makeInstance(TranslateViewHelper
::class);
39 $this->injectDependenciesIntoViewHelper($this->subject
);
40 $this->subject
->render();
46 public function renderReturnsStringForGivenKey() {
47 $this->subject
= GeneralUtility
::makeInstance(TranslateViewHelperFixtureForTranslatedString
::class);
48 $this->injectDependenciesIntoViewHelper($this->subject
);
49 $this->assertEquals('<p>hello world</p>', $this->subject
->render('foo'));
55 public function renderReturnsStringForGivenId() {
56 $this->subject
= GeneralUtility
::makeInstance(TranslateViewHelperFixtureForTranslatedString
::class);
57 $this->injectDependenciesIntoViewHelper($this->subject
);
58 $this->assertEquals('<p>hello world</p>', $this->subject
->render(NULL, 'bar'));
64 public function renderReturnsDefaultIfNoTranslationIsFound() {
65 $this->subject
= GeneralUtility
::makeInstance(TranslateViewHelperFixtureForEmptyString
::class);
66 $this->injectDependenciesIntoViewHelper($this->subject
);
67 $this->assertEquals('default', $this->subject
->render(NULL, 'bar', 'default'));
73 public function resultIsNotHtmlEscapedIfSoRequested() {
74 $this->subject
= GeneralUtility
::makeInstance(TranslateViewHelperFixtureForTranslatedString
::class);
75 $this->injectDependenciesIntoViewHelper($this->subject
);
76 $this->assertEquals('<p>hello world</p>', $this->subject
->render('foo', NULL, NULL, TRUE));