‪TYPO3CMS  9.5
ExternalViewHelperTest.php
Go to the documentation of this file.
1 <?php
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  */
16 
18 use TYPO3\TestingFramework\Fluid\Unit\ViewHelpers\ViewHelperBaseTestcase;
19 
23 class ‪ExternalViewHelperTest extends ViewHelperBaseTestcase
24 {
28  protected ‪$viewHelper;
29 
30  protected function ‪setUp()
31  {
32  parent::setUp();
33  $this->viewHelper = new ‪ExternalViewHelper();
34  $this->injectDependenciesIntoViewHelper($this->viewHelper);
35  $this->viewHelper->setRenderChildrenClosure(
36  function () {
37  return 'http://www.some-domain.tld';
38  }
39  );
40  }
41 
45  public function ‪renderReturnsSpecifiedUri()
46  {
47  $this->setArgumentsUnderTest(
48  $this->viewHelper,
49  [
50  'uri' => 'http://www.some-domain.tld'
51  ]
52  );
53  $actualResult = $this->viewHelper->initializeArgumentsAndRender();
54  $this->assertEquals('http://www.some-domain.tld', $actualResult);
55  }
56 
61  {
62  $this->setArgumentsUnderTest(
63  $this->viewHelper,
64  [
65  'uri' => 'www.some-domain.tld',
66  ]
67  );
68  $actualResult = $this->viewHelper->initializeArgumentsAndRender();
69  $this->assertEquals('http://www.some-domain.tld', $actualResult);
70  }
71 
76  {
77  $this->setArgumentsUnderTest(
78  $this->viewHelper,
79  [
80  'uri' => 'some-domain.tld',
81  'defaultScheme' => 'ftp'
82  ]
83  );
84  $actualResult = $this->viewHelper->initializeArgumentsAndRender();
85  $this->assertEquals('ftp://some-domain.tld', $actualResult);
86  }
87 
91  public function ‪renderDoesNotAddEmptyScheme()
92  {
93  $this->setArgumentsUnderTest(
94  $this->viewHelper,
95  [
96  'uri' => 'some-domain.tld',
97  'defaultScheme' => ''
98  ]
99  );
100  $actualResult = $this->viewHelper->initializeArgumentsAndRender();
101  $this->assertEquals('some-domain.tld', $actualResult);
102  }
103 }
‪TYPO3\CMS\Fluid\Tests\Unit\ViewHelpers\Uri\ExternalViewHelperTest\setUp
‪setUp()
Definition: ExternalViewHelperTest.php:29
‪TYPO3\CMS\Fluid\Tests\Unit\ViewHelpers\Uri\ExternalViewHelperTest\renderAddsHttpPrefixIfSpecifiedUriDoesNotContainScheme
‪renderAddsHttpPrefixIfSpecifiedUriDoesNotContainScheme()
Definition: ExternalViewHelperTest.php:59
‪TYPO3\CMS\Fluid\Tests\Unit\ViewHelpers\Uri
Definition: EmailViewHelperTest.php:2
‪TYPO3\CMS\Fluid\Tests\Unit\ViewHelpers\Uri\ExternalViewHelperTest\renderReturnsSpecifiedUri
‪renderReturnsSpecifiedUri()
Definition: ExternalViewHelperTest.php:44
‪TYPO3\CMS\Fluid\ViewHelpers\Uri\ExternalViewHelper
Definition: ExternalViewHelper.php:47
‪TYPO3\CMS\Fluid\Tests\Unit\ViewHelpers\Uri\ExternalViewHelperTest\$viewHelper
‪TYPO3 CMS Fluid ViewHelpers Uri ExternalViewHelper $viewHelper
Definition: ExternalViewHelperTest.php:27
‪TYPO3\CMS\Fluid\Tests\Unit\ViewHelpers\Uri\ExternalViewHelperTest
Definition: ExternalViewHelperTest.php:24
‪TYPO3\CMS\Fluid\Tests\Unit\ViewHelpers\Uri\ExternalViewHelperTest\renderAddsSpecifiedSchemeIfUriDoesNotContainScheme
‪renderAddsSpecifiedSchemeIfUriDoesNotContainScheme()
Definition: ExternalViewHelperTest.php:74
‪TYPO3\CMS\Fluid\Tests\Unit\ViewHelpers\Uri\ExternalViewHelperTest\renderDoesNotAddEmptyScheme
‪renderDoesNotAddEmptyScheme()
Definition: ExternalViewHelperTest.php:90