‪TYPO3CMS  10.4
Nl2brViewHelperTest.php
Go to the documentation of this file.
1 <?php
2 
3 /*
4  * This file is part of the TYPO3 CMS project.
5  *
6  * It is free software; you can redistribute it and/or modify it under
7  * the terms of the GNU General Public License, either version 2
8  * of the License, or any later version.
9  *
10  * For the full copyright and license information, please read the
11  * LICENSE.txt file that was distributed with this source code.
12  *
13  * The TYPO3 project - inspiring people to share!
14  */
15 
17 
19 use TYPO3\TestingFramework\Fluid\Unit\ViewHelpers\ViewHelperBaseTestcase;
20 
24 class ‪Nl2brViewHelperTest extends ViewHelperBaseTestcase
25 {
29  protected ‪$viewHelper;
30 
31  protected function ‪setUp(): void
32  {
33  parent::setUp();
34  $this->viewHelper = new ‪Nl2brViewHelper();
35  $this->injectDependenciesIntoViewHelper($this->viewHelper);
36  }
37 
42  {
43  $this->viewHelper->setRenderChildrenClosure(
44  function () {
45  return '<p class="bodytext">Some Text without line breaks</p>';
46  }
47  );
48  $this->setArgumentsUnderTest(
49  $this->viewHelper,
50  [
51  ]
52  );
53  $actualResult = $this->viewHelper->initializeArgumentsAndRender();
54  self::assertEquals('<p class="bodytext">Some Text without line breaks</p>', $actualResult);
55  }
56 
61  {
62  $this->viewHelper->setRenderChildrenClosure(
63  function () {
64  return 'Line 1' . chr(10) . 'Line 2';
65  }
66  );
67  $this->setArgumentsUnderTest(
68  $this->viewHelper,
69  [
70  ]
71  );
72  $actualResult = $this->viewHelper->initializeArgumentsAndRender();
73  self::assertEquals('Line 1<br />' . chr(10) . 'Line 2', $actualResult);
74  }
75 
80  {
81  $this->viewHelper->setRenderChildrenClosure(
82  function () {
83  return 'Line 1' . chr(13) . chr(10) . 'Line 2';
84  }
85  );
86  $this->setArgumentsUnderTest(
87  $this->viewHelper,
88  [
89  ]
90  );
91  $actualResult = $this->viewHelper->initializeArgumentsAndRender();
92  self::assertEquals('Line 1<br />' . chr(13) . chr(10) . 'Line 2', $actualResult);
93  }
94 }
‪TYPO3\CMS\Fluid\Tests\Unit\ViewHelpers\Format\Nl2brViewHelperTest\viewHelperDoesNotModifyTextWithoutLineBreaks
‪viewHelperDoesNotModifyTextWithoutLineBreaks()
Definition: Nl2brViewHelperTest.php:40
‪TYPO3\CMS\Fluid\Tests\Unit\ViewHelpers\Format\Nl2brViewHelperTest\$viewHelper
‪Nl2brViewHelper $viewHelper
Definition: Nl2brViewHelperTest.php:28
‪TYPO3\CMS\Fluid\Tests\Unit\ViewHelpers\Format\Nl2brViewHelperTest
Definition: Nl2brViewHelperTest.php:25
‪TYPO3\CMS\Fluid\Tests\Unit\ViewHelpers\Format
Definition: ScriptViewHelperTest.php:18
‪TYPO3\CMS\Fluid\Tests\Unit\ViewHelpers\Format\Nl2brViewHelperTest\viewHelperConvertsLineBreaksToBRTags
‪viewHelperConvertsLineBreaksToBRTags()
Definition: Nl2brViewHelperTest.php:59
‪TYPO3\CMS\Fluid\Tests\Unit\ViewHelpers\Format\Nl2brViewHelperTest\viewHelperConvertsWindowsLineBreaksToBRTags
‪viewHelperConvertsWindowsLineBreaksToBRTags()
Definition: Nl2brViewHelperTest.php:78
‪TYPO3\CMS\Fluid\ViewHelpers\Format\Nl2brViewHelper
Definition: Nl2brViewHelper.php:48
‪TYPO3\CMS\Fluid\Tests\Unit\ViewHelpers\Format\Nl2brViewHelperTest\setUp
‪setUp()
Definition: Nl2brViewHelperTest.php:30