TYPO3  7.6
StripTagsViewHelperTest.php
Go to the documentation of this file.
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 
15 
20 {
24  protected $viewHelper;
25 
26  protected function setUp()
27  {
28  parent::setUp();
29  $this->viewHelper = $this->getMock(\TYPO3\CMS\Fluid\ViewHelpers\Format\StripTagsViewHelper::class, array('renderChildren'));
30  $this->injectDependenciesIntoViewHelper($this->viewHelper);
31  $this->viewHelper->initializeArguments();
32  }
33 
38  {
39  $this->assertFalse($this->viewHelper->isEscapingInterceptorEnabled());
40  }
41 
46  {
47  $this->viewHelper->expects($this->never())->method('renderChildren');
48  $actualResult = $this->viewHelper->render('Some string');
49  $this->assertEquals('Some string', $actualResult);
50  }
51 
56  {
57  $this->viewHelper->expects($this->atLeastOnce())->method('renderChildren')->will($this->returnValue('Some string'));
58  $actualResult = $this->viewHelper->render();
59  $this->assertEquals('Some string', $actualResult);
60  }
61 
67  public function stringsTestDataProvider()
68  {
69  return array(
70  array('This is a sample text without special characters.', 'This is a sample text without special characters.'),
71  array('This is a sample text <b>with <i>some</i> tags</b>.', 'This is a sample text with some tags.'),
72  array('This text contains some &quot;&Uuml;mlaut&quot;.', 'This text contains some &quot;&Uuml;mlaut&quot;.')
73  );
74  }
75 
80  public function renderCorrectlyConvertsIntoPlaintext($source, $expectedResult)
81  {
82  $actualResult = $this->viewHelper->render($source);
83  $this->assertSame($expectedResult, $actualResult);
84  }
85 
90  {
91  $source = new \stdClass();
92  $actualResult = $this->viewHelper->render($source);
93  $this->assertSame($source, $actualResult);
94  }
95 }