[+FEATURE] Fluid (ViewHelpers): prepend URIs with scheme if it's not specified in...
[Packages/TYPO3.CMS.git] / typo3 / sysext / fluid / Tests / Unit / ViewHelpers / Uri / ExternalViewHelperTest.php
1 <?php
2
3 /* *
4 * This script belongs to the FLOW3 package "Fluid". *
5 * *
6 * It is free software; you can redistribute it and/or modify it under *
7 * the terms of the GNU Lesser General Public License as published by the *
8 * Free Software Foundation, either version 3 of the License, or (at your *
9 * option) any later version. *
10 * *
11 * This script is distributed in the hope that it will be useful, but *
12 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHAN- *
13 * TABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser *
14 * General Public License for more details. *
15 * *
16 * You should have received a copy of the GNU Lesser General Public *
17 * License along with the script. *
18 * If not, see http://www.gnu.org/licenses/lgpl.html *
19 * *
20 * The TYPO3 project - inspiring people to share! *
21 * */
22
23 require_once(dirname(__FILE__) . '/../ViewHelperBaseTestcase.php');
24
25 /**
26 * Testcase for the external uri view helper
27 *
28 * @license http://www.gnu.org/licenses/lgpl.html GNU Lesser General Public License, version 3 or later
29 */
30 class Tx_Fluid_Tests_Unit_ViewHelpers_Uri_ExternalViewHelperTest extends Tx_Fluid_ViewHelpers_ViewHelperBaseTestcase {
31
32 /**
33 * var Tx_Fluid_ViewHelpers_Uri_ExternalViewHelper
34 */
35 protected $viewHelper;
36
37 public function setUp() {
38 parent::setUp();
39 $this->viewHelper = new Tx_Fluid_ViewHelpers_Uri_ExternalViewHelper();
40 $this->injectDependenciesIntoViewHelper($this->viewHelper);
41 $this->viewHelper->initializeArguments();
42 }
43
44 /**
45 * @test
46 * @author Bastian Waidelich <bastian@typo3.org>
47 */
48 public function renderReturnsSpecifiedUri() {
49 $this->viewHelper->initialize();
50 $actualResult = $this->viewHelper->render('http://www.some-domain.tld');
51
52 $this->assertEquals('http://www.some-domain.tld', $actualResult);
53 }
54
55 /**
56 * @test
57 * @author Bastian Waidelich <bastian@typo3.org>
58 */
59 public function renderAddsHttpPrefixIfSpecifiedUriDoesNotContainScheme() {
60 $this->viewHelper->initialize();
61 $actualResult = $this->viewHelper->render('www.some-domain.tld');
62
63 $this->assertEquals('http://www.some-domain.tld', $actualResult);
64 }
65
66 /**
67 * @test
68 * @author Bastian Waidelich <bastian@typo3.org>
69 */
70 public function renderAddsSpecifiedSchemeIfUriDoesNotContainScheme() {
71 $this->viewHelper->initialize();
72 $actualResult = $this->viewHelper->render('some-domain.tld', 'ftp');
73
74 $this->assertEquals('ftp://some-domain.tld', $actualResult);
75 }
76
77 /**
78 * @test
79 * @author Bastian Waidelich <bastian@typo3.org>
80 */
81 public function renderDoesNotAddEmptyScheme() {
82 $this->viewHelper->initialize();
83 $actualResult = $this->viewHelper->render('some-domain.tld', '');
84
85 $this->assertEquals('some-domain.tld', $actualResult);
86 }
87 }
88
89
90 ?>