TYPO3 CMS  TYPO3_7-6
Nl2brViewHelperTest.php
Go to the documentation of this file.
1 <?php
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 
16 
21 {
25  protected $viewHelper;
26 
27  protected function setUp()
28  {
29  parent::setUp();
30  $this->viewHelper = $this->getMock(Nl2brViewHelper::class, ['renderChildren']);
31  $this->injectDependenciesIntoViewHelper($this->viewHelper);
32  $this->viewHelper->initializeArguments();
33  }
34 
39  {
40  $this->viewHelper->expects($this->once())->method('renderChildren')->will($this->returnValue('<p class="bodytext">Some Text without line breaks</p>'));
41  $actualResult = $this->viewHelper->render();
42  $this->assertEquals('<p class="bodytext">Some Text without line breaks</p>', $actualResult);
43  }
44 
49  {
50  $this->viewHelper->expects($this->once())->method('renderChildren')->will($this->returnValue('Line 1' . chr(10) . 'Line 2'));
51  $actualResult = $this->viewHelper->render();
52  $this->assertEquals('Line 1<br />' . chr(10) . 'Line 2', $actualResult);
53  }
54 
59  {
60  $this->viewHelper->expects($this->once())->method('renderChildren')->will($this->returnValue('Line 1' . chr(13) . chr(10) . 'Line 2'));
61  $actualResult = $this->viewHelper->render();
62  $this->assertEquals('Line 1<br />' . chr(13) . chr(10) . 'Line 2', $actualResult);
63  }
64 }
injectDependenciesIntoViewHelper(\TYPO3\CMS\Fluid\Core\ViewHelper\AbstractViewHelper $viewHelper)