TYPO3 CMS  TYPO3_7-6
UrlencodeViewHelperTest.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  * */
16 
21 {
25  protected $viewHelper;
26 
27  protected function setUp()
28  {
29  $this->viewHelper = $this->getMock(UrlencodeViewHelper::class, ['renderChildren']);
30 
32  $renderingContext = $this->getMock(RenderingContext::class);
33  $this->viewHelper->setRenderingContext($renderingContext);
34  }
35 
40  {
41  $this->assertFalse($this->viewHelper->isEscapingInterceptorEnabled());
42  }
43 
48  {
49  $this->viewHelper->expects($this->never())->method('renderChildren');
50  $actualResult = $this->viewHelper->render('Source');
51  $this->assertEquals('Source', $actualResult);
52  }
53 
58  {
59  $this->viewHelper->expects($this->atLeastOnce())->method('renderChildren')->will($this->returnValue('Source'));
60  $actualResult = $this->viewHelper->render();
61  $this->assertEquals('Source', $actualResult);
62  }
63 
68  {
69  $source = 'StringWithoutSpecialCharacters';
70  $actualResult = $this->viewHelper->render($source);
71  $this->assertSame($source, $actualResult);
72  }
73 
77  public function renderEncodesString()
78  {
79  $source = 'Foo @+%/ "';
80  $expectedResult = 'Foo%20%40%2B%25%2F%20%22';
81  $actualResult = $this->viewHelper->render($source);
82  $this->assertEquals($expectedResult, $actualResult);
83  }
84 
89  {
90  $source = new \stdClass();
91  $actualResult = $this->viewHelper->render($source);
92  $this->assertSame($source, $actualResult);
93  }
94 }