[TASK] Move arguments to initializeArguments() in Nl2brVH in ext:fluid
[Packages/TYPO3.CMS.git] / typo3 / sysext / fluid / Tests / Unit / ViewHelpers / Format / Nl2brViewHelperTest.php
1 <?php
2 namespace TYPO3\CMS\Fluid\Tests\Unit\ViewHelpers\Format;
3
4 /*
5 * This file is part of the TYPO3 CMS project.
6 *
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.
10 *
11 * For the full copyright and license information, please read the
12 * LICENSE.txt file that was distributed with this source code.
13 *
14 * The TYPO3 project - inspiring people to share!
15 */
16 use TYPO3\CMS\Fluid\Tests\Unit\ViewHelpers\ViewHelperBaseTestcase;
17 use TYPO3\CMS\Fluid\ViewHelpers\Format\Nl2brViewHelper;
18
19 /**
20 * Test case
21 */
22 class Nl2brViewHelperTest extends ViewHelperBaseTestcase
23 {
24 /**
25 * @var Nl2brViewHelper
26 */
27 protected $viewHelper;
28
29 protected function setUp()
30 {
31 parent::setUp();
32 $this->viewHelper = new Nl2brViewHelper();
33 $this->injectDependenciesIntoViewHelper($this->viewHelper);
34 }
35
36 /**
37 * @test
38 */
39 public function viewHelperDoesNotModifyTextWithoutLineBreaks()
40 {
41 $this->viewHelper->setRenderChildrenClosure(
42 function () {
43 return '<p class="bodytext">Some Text without line breaks</p>';
44 }
45 );
46 $this->setArgumentsUnderTest(
47 $this->viewHelper,
48 [
49 ]
50 );
51 $actualResult = $this->viewHelper->initializeArgumentsAndRender();
52 $this->assertEquals('<p class="bodytext">Some Text without line breaks</p>', $actualResult);
53 }
54
55 /**
56 * @test
57 */
58 public function viewHelperConvertsLineBreaksToBRTags()
59 {
60 $this->viewHelper->setRenderChildrenClosure(
61 function () {
62 return 'Line 1' . chr(10) . 'Line 2';
63 }
64 );
65 $this->setArgumentsUnderTest(
66 $this->viewHelper,
67 [
68 ]
69 );
70 $actualResult = $this->viewHelper->initializeArgumentsAndRender();
71 $this->assertEquals('Line 1<br />' . chr(10) . 'Line 2', $actualResult);
72 }
73
74 /**
75 * @test
76 */
77 public function viewHelperConvertsWindowsLineBreaksToBRTags()
78 {
79 $this->viewHelper->setRenderChildrenClosure(
80 function () {
81 return 'Line 1' . chr(13) . chr(10) . 'Line 2';
82 }
83 );
84 $this->setArgumentsUnderTest(
85 $this->viewHelper,
86 [
87 ]
88 );
89 $actualResult = $this->viewHelper->initializeArgumentsAndRender();
90 $this->assertEquals('Line 1<br />' . chr(13) . chr(10) . 'Line 2', $actualResult);
91 }
92 }