TYPO3 CMS  TYPO3_6-2
HtmlentitiesDecodeViewHelperTest.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 
18 
22  protected $viewHelper;
23 
24  public function setUp() {
25  $this->viewHelper = $this->getMock('TYPO3\\CMS\\Fluid\\ViewHelpers\\Format\\HtmlentitiesDecodeViewHelper', array('renderChildren'));
26  }
27 
32  $this->assertFalse($this->viewHelper->isEscapingInterceptorEnabled());
33  }
34 
39  $this->viewHelper->expects($this->never())->method('renderChildren');
40  $actualResult = $this->viewHelper->render('Some string');
41  $this->assertEquals('Some string', $actualResult);
42  }
43 
48  $this->viewHelper->expects($this->atLeastOnce())->method('renderChildren')->will($this->returnValue('Some string'));
49  $actualResult = $this->viewHelper->render();
50  $this->assertEquals('Some string', $actualResult);
51  }
52 
57  $source = 'This is a sample text without special characters. <> &©"\'';
58  $actualResult = $this->viewHelper->render($source);
59  $this->assertSame($source, $actualResult);
60  }
61 
65  public function renderDecodesSimpleString() {
66  $source = 'Some special characters: &amp; &quot; \' &lt; &gt; *';
67  $expectedResult = 'Some special characters: & " \' < > *';
68  $actualResult = $this->viewHelper->render($source);
69  $this->assertEquals($expectedResult, $actualResult);
70  }
71 
75  public function renderRespectsKeepQuoteArgument() {
76  $source = 'Some special characters: &amp; &quot; \' &lt; &gt; *';
77  $expectedResult = 'Some special characters: & &quot; \' < > *';
78  $actualResult = $this->viewHelper->render($source, TRUE);
79  $this->assertEquals($expectedResult, $actualResult);
80  }
81 
85  public function renderRespectsEncodingArgument() {
86  $source = utf8_decode('Some special characters: &amp; &quot; \' &lt; &gt; *');
87  $expectedResult = 'Some special characters: & " \' < > *';
88  $actualResult = $this->viewHelper->render($source, FALSE, 'ISO-8859-1');
89  $this->assertEquals($expectedResult, $actualResult);
90  }
91 
96  $source = new \stdClass();
97  $actualResult = $this->viewHelper->render($source);
98  $this->assertSame($source, $actualResult);
99  }
100 }