TYPO3CMS  8
 All Classes Namespaces Files Functions Variables Pages
UrlencodeViewHelperTest.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 UrlencodeViewHelper();
33  $this->injectDependenciesIntoViewHelper($this->viewHelper);
34  }
35 
40  {
41  $this->setArgumentsUnderTest(
42  $this->viewHelper,
43  [
44  'value' => 'Source'
45  ]
46  );
47  $actualResult = $this->viewHelper->initializeArgumentsAndRender();
48  $this->assertEquals('Source', $actualResult);
49  }
50 
55  {
56  $this->setArgumentsUnderTest(
57  $this->viewHelper,
58  [
59  'value' => 'Source'
60  ]
61  );
62 
63  $actualResult = $this->viewHelper->initializeArgumentsAndRender();
64  $this->assertEquals('Source', $actualResult);
65  }
66 
71  {
72  $source = 'StringWithoutSpecialCharacters';
73 
74  $this->setArgumentsUnderTest(
75  $this->viewHelper,
76  [
77  'value' => $source
78  ]
79  );
80  $actualResult = $this->viewHelper->initializeArgumentsAndRender();
81  $this->assertSame($source, $actualResult);
82  }
83 
87  public function renderEncodesString()
88  {
89  $source = 'Foo @+%/ "';
90  $expectedResult = 'Foo%20%40%2B%25%2F%20%22';
91 
92  $this->setArgumentsUnderTest(
93  $this->viewHelper,
94  [
95  'value' => $source
96  ]
97  );
98 
99  $actualResult = $this->viewHelper->initializeArgumentsAndRender();
100  $this->assertEquals($expectedResult, $actualResult);
101  }
102 
107  {
108  $source = new \stdClass();
109 
110  $this->setArgumentsUnderTest(
111  $this->viewHelper,
112  [
113  'value' => $source
114  ]
115  );
116 
117  $actualResult = $this->viewHelper->render();
118  $this->assertSame($source, $actualResult);
119  }
120 }
setArgumentsUnderTest(ViewHelperInterface $viewHelper, array $arguments=[])