‪TYPO3CMS  9.5
TemplateServiceTest.php
Go to the documentation of this file.
1 <?php
2 declare(strict_types = 1);
3 
5 
6 /*
7  * This file is part of the TYPO3 CMS project.
8  *
9  * It is free software; you can redistribute it and/or modify it under
10  * the terms of the GNU General Public License, either version 2
11  * of the License, or any later version.
12  *
13  * For the full copyright and license information, please read the
14  * LICENSE.txt file that was distributed with this source code.
15  *
16  * The TYPO3 project - inspiring people to share!
17  */
18 
20 use TYPO3\CMS\Core\Package\PackageManager;
22 use TYPO3\TestingFramework\Core\Unit\UnitTestCase;
23 
27 class ‪TemplateServiceTest extends UnitTestCase
28 {
32  protected ‪$templateService;
33 
37  protected function ‪setUp(): void
38  {
39  $packageManagerProphecy = $this->prophesize(PackageManager::class);
40  $this->templateService = new ‪TemplateService(new ‪Context(), $packageManagerProphecy->reveal());
41  }
42 
46  public function ‪getFileNameReturnsUrlCorrectly(): void
47  {
48  $this->assertSame('http://example.com', $this->templateService->getFileName('http://example.com'));
49  $this->assertSame('https://example.com', $this->templateService->getFileName('https://example.com'));
50  }
51 
55  public function ‪getFileNameReturnsFileCorrectly(): void
56  {
57  $this->assertSame('typo3/index.php', $this->templateService->getFileName('typo3/index.php'));
58  }
59 
63  public function ‪getFileNameReturnsNullIfDirectory(): void
64  {
65  $this->assertNull($this->templateService->getFileName(__DIR__));
66  }
67 
71  public function ‪getFileNameReturnsNullWithInvalidFileName(): void
72  {
73  $this->assertNull($this->templateService->getFileName(' '));
74  $this->assertNull($this->templateService->getFileName('something/../else'));
75  }
76 }
‪TYPO3\CMS\Core\Tests\UnitDeprecated\TypoScript\TemplateServiceTest\getFileNameReturnsNullIfDirectory
‪getFileNameReturnsNullIfDirectory()
Definition: TemplateServiceTest.php:62
‪TYPO3\CMS\Core\Tests\UnitDeprecated\TypoScript\TemplateServiceTest\setUp
‪setUp()
Definition: TemplateServiceTest.php:36
‪TYPO3\CMS\Core\Tests\UnitDeprecated\TypoScript\TemplateServiceTest\getFileNameReturnsUrlCorrectly
‪getFileNameReturnsUrlCorrectly()
Definition: TemplateServiceTest.php:45
‪TYPO3\CMS\Core\Context\Context
Definition: Context.php:49
‪TYPO3\CMS\Core\Tests\UnitDeprecated\TypoScript\TemplateServiceTest
Definition: TemplateServiceTest.php:28
‪TYPO3\CMS\Core\TypoScript\TemplateService
Definition: TemplateService.php:50
‪TYPO3\CMS\Core\Tests\UnitDeprecated\TypoScript\TemplateServiceTest\$templateService
‪TemplateService $templateService
Definition: TemplateServiceTest.php:31
‪TYPO3\CMS\Core\Tests\UnitDeprecated\TypoScript\TemplateServiceTest\getFileNameReturnsNullWithInvalidFileName
‪getFileNameReturnsNullWithInvalidFileName()
Definition: TemplateServiceTest.php:70
‪TYPO3\CMS\Core\Tests\UnitDeprecated\TypoScript
Definition: TemplateServiceTest.php:4
‪TYPO3\CMS\Core\Tests\UnitDeprecated\TypoScript\TemplateServiceTest\getFileNameReturnsFileCorrectly
‪getFileNameReturnsFileCorrectly()
Definition: TemplateServiceTest.php:54