[TASK] Use ::class where possible in fluid unit tests
[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 script is backported from the TYPO3 Flow package "TYPO3.Fluid". *
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 3 of the *
9 * License, or (at your option) any later version. *
10 * *
11 * The TYPO3 project - inspiring people to share! *
12 * */
13
14 use TYPO3\CMS\Fluid\Tests\Unit\ViewHelpers\ViewHelperBaseTestcase;
15 use TYPO3\CMS\Fluid\ViewHelpers\Format\Nl2brViewHelper;
16
17 /**
18 * Test case
19 */
20 class Nl2brViewHelperTest extends ViewHelperBaseTestcase {
21
22 /**
23 * @var Nl2brViewHelper
24 */
25 protected $viewHelper;
26
27 protected function setUp() {
28 parent::setUp();
29 $this->viewHelper = $this->getMock(Nl2brViewHelper::class, array('renderChildren'));
30 $this->injectDependenciesIntoViewHelper($this->viewHelper);
31 $this->viewHelper->initializeArguments();
32 }
33
34 /**
35 * @test
36 */
37 public function viewHelperDoesNotModifyTextWithoutLineBreaks() {
38 $this->viewHelper->expects($this->once())->method('renderChildren')->will($this->returnValue('<p class="bodytext">Some Text without line breaks</p>'));
39 $actualResult = $this->viewHelper->render();
40 $this->assertEquals('<p class="bodytext">Some Text without line breaks</p>', $actualResult);
41 }
42
43 /**
44 * @test
45 */
46 public function viewHelperConvertsLineBreaksToBRTags() {
47 $this->viewHelper->expects($this->once())->method('renderChildren')->will($this->returnValue('Line 1' . chr(10) . 'Line 2'));
48 $actualResult = $this->viewHelper->render();
49 $this->assertEquals('Line 1<br />' . chr(10) . 'Line 2', $actualResult);
50 }
51
52 /**
53 * @test
54 */
55 public function viewHelperConvertsWindowsLineBreaksToBRTags() {
56 $this->viewHelper->expects($this->once())->method('renderChildren')->will($this->returnValue('Line 1' . chr(13) . chr(10) . 'Line 2'));
57 $actualResult = $this->viewHelper->render();
58 $this->assertEquals('Line 1<br />' . chr(13) . chr(10) . 'Line 2', $actualResult);
59 }
60
61 }