TYPO3CMS  8
 All Classes Namespaces Files Functions Variables Pages
StripTagsViewHelperTest.php
Go to the documentation of this file.
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  */
18 
23 {
27  protected $viewHelper;
28 
29  protected function setUp()
30  {
31  parent::setUp();
32  $this->viewHelper = new StripTagsViewHelper();
33  $this->injectDependenciesIntoViewHelper($this->viewHelper);
34  }
35 
40  {
41  $this->setArgumentsUnderTest(
42  $this->viewHelper,
43  [
44  'value' => 'Some string',
45  ]
46  );
47  $actualResult = $this->viewHelper->initializeArgumentsAndRender();
48  $this->assertEquals('Some string', $actualResult);
49  }
50 
55  {
56  $this->setArgumentsUnderTest(
57  $this->viewHelper,
58  [
59  'value' => 'Some string',
60  ]
61  );
62  $actualResult = $this->viewHelper->initializeArgumentsAndRender();
63  $this->assertEquals('Some string', $actualResult);
64  }
65 
71  public function stringsTestDataProvider()
72  {
73  return [
74  ['This is a sample text without special characters.', '', 'This is a sample text without special characters.'],
75  ['This is a sample text <b>with <i>some</i> tags</b>.', '', 'This is a sample text with some tags.'],
76  ['This text contains some &quot;&Uuml;mlaut&quot;.', '', 'This text contains some &quot;&Uuml;mlaut&quot;.'],
77  ['This text <i>contains</i> some <strong>allowed</strong> tags.', '<strong>', 'This text contains some <strong>allowed</strong> tags.'],
78  ];
79  }
80 
88  public function renderCorrectlyConvertsIntoPlaintext($source, $allowed, $expectedResult)
89  {
90  $this->setArgumentsUnderTest(
91  $this->viewHelper,
92  [
93  'value' => $source,
94  'allowedTags' => $allowed
95  ]
96  );
97  $actualResult = $this->viewHelper->initializeArgumentsAndRender();
98  $this->assertSame($expectedResult, $actualResult);
99  }
100 
105  {
106  $source = new \stdClass();
107  $this->setArgumentsUnderTest(
108  $this->viewHelper,
109  [
110  'value' => $source
111  ]
112  );
113  $actualResult = $this->viewHelper->render();
114  $this->assertSame($source, $actualResult);
115  }
116 }
setArgumentsUnderTest(ViewHelperInterface $viewHelper, array $arguments=[])