‪TYPO3CMS  10.4
ExternalViewHelperTest.php
Go to the documentation of this file.
1 <?php
2 
3 /*
4  * This file is part of the TYPO3 CMS project.
5  *
6  * It is free software; you can redistribute it and/or modify it under
7  * the terms of the GNU General Public License, either version 2
8  * of the License, or any later version.
9  *
10  * For the full copyright and license information, please read the
11  * LICENSE.txt file that was distributed with this source code.
12  *
13  * The TYPO3 project - inspiring people to share!
14  */
15 
17 
19 use TYPO3\TestingFramework\Fluid\Unit\ViewHelpers\ViewHelperBaseTestcase;
20 
24 class ‪ExternalViewHelperTest extends ViewHelperBaseTestcase
25 {
29  protected ‪$viewHelper;
30 
31  protected function ‪setUp(): void
32  {
33  parent::setUp();
34  $this->viewHelper = new ‪ExternalViewHelper();
35  $this->injectDependenciesIntoViewHelper($this->viewHelper);
36  $this->viewHelper->setRenderChildrenClosure(
37  function () {
38  return 'http://www.some-domain.tld';
39  }
40  );
41  }
42 
46  public function ‪renderReturnsSpecifiedUri()
47  {
48  $this->setArgumentsUnderTest(
49  $this->viewHelper,
50  [
51  'uri' => 'http://www.some-domain.tld'
52  ]
53  );
54  $actualResult = $this->viewHelper->initializeArgumentsAndRender();
55  self::assertEquals('http://www.some-domain.tld', $actualResult);
56  }
57 
62  {
63  $this->setArgumentsUnderTest(
64  $this->viewHelper,
65  [
66  'uri' => 'www.some-domain.tld',
67  ]
68  );
69  $actualResult = $this->viewHelper->initializeArgumentsAndRender();
70  self::assertEquals('http://www.some-domain.tld', $actualResult);
71  }
72 
77  {
78  $this->setArgumentsUnderTest(
79  $this->viewHelper,
80  [
81  'uri' => 'some-domain.tld',
82  'defaultScheme' => 'ftp'
83  ]
84  );
85  $actualResult = $this->viewHelper->initializeArgumentsAndRender();
86  self::assertEquals('ftp://some-domain.tld', $actualResult);
87  }
88 
92  public function ‪renderDoesNotAddEmptyScheme()
93  {
94  $this->setArgumentsUnderTest(
95  $this->viewHelper,
96  [
97  'uri' => 'some-domain.tld',
98  'defaultScheme' => ''
99  ]
100  );
101  $actualResult = $this->viewHelper->initializeArgumentsAndRender();
102  self::assertEquals('some-domain.tld', $actualResult);
103  }
104 }
‪TYPO3\CMS\Fluid\Tests\Unit\ViewHelpers\Uri\ExternalViewHelperTest\setUp
‪setUp()
Definition: ExternalViewHelperTest.php:30
‪TYPO3\CMS\Fluid\Tests\Unit\ViewHelpers\Uri\ExternalViewHelperTest\renderAddsHttpPrefixIfSpecifiedUriDoesNotContainScheme
‪renderAddsHttpPrefixIfSpecifiedUriDoesNotContainScheme()
Definition: ExternalViewHelperTest.php:60
‪TYPO3\CMS\Fluid\Tests\Unit\ViewHelpers\Uri
Definition: EmailViewHelperTest.php:16
‪TYPO3\CMS\Fluid\Tests\Unit\ViewHelpers\Uri\ExternalViewHelperTest\renderReturnsSpecifiedUri
‪renderReturnsSpecifiedUri()
Definition: ExternalViewHelperTest.php:45
‪TYPO3\CMS\Fluid\ViewHelpers\Uri\ExternalViewHelper
Definition: ExternalViewHelper.php:48
‪TYPO3\CMS\Fluid\Tests\Unit\ViewHelpers\Uri\ExternalViewHelperTest\$viewHelper
‪TYPO3 CMS Fluid ViewHelpers Uri ExternalViewHelper $viewHelper
Definition: ExternalViewHelperTest.php:28
‪TYPO3\CMS\Fluid\Tests\Unit\ViewHelpers\Uri\ExternalViewHelperTest
Definition: ExternalViewHelperTest.php:25
‪TYPO3\CMS\Fluid\Tests\Unit\ViewHelpers\Uri\ExternalViewHelperTest\renderAddsSpecifiedSchemeIfUriDoesNotContainScheme
‪renderAddsSpecifiedSchemeIfUriDoesNotContainScheme()
Definition: ExternalViewHelperTest.php:75
‪TYPO3\CMS\Fluid\Tests\Unit\ViewHelpers\Uri\ExternalViewHelperTest\renderDoesNotAddEmptyScheme
‪renderDoesNotAddEmptyScheme()
Definition: ExternalViewHelperTest.php:91