8c1f49c6529910bc2d6acc4bcc0afa8658b96ccb
[Packages/TYPO3.CMS.git] / typo3 / sysext / core / Tests / UnitDeprecated / TypoScript / TemplateServiceTest.php
1 <?php
2 declare(strict_types = 1);
3
4 namespace TYPO3\CMS\Core\Tests\UnitDeprecated\TypoScript;
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
19 use TYPO3\CMS\Core\Context\Context;
20 use TYPO3\CMS\Core\TypoScript\TemplateService;
21 use TYPO3\TestingFramework\Core\Unit\UnitTestCase;
22
23 /**
24 * Test case
25 */
26 class TemplateServiceTest extends UnitTestCase
27 {
28 /**
29 * @var TemplateService
30 */
31 protected $templateService;
32
33 /**
34 * Set up
35 */
36 protected function setUp(): void
37 {
38 $this->templateService = new TemplateService(new Context());
39 }
40
41 /**
42 * @test
43 */
44 public function getFileNameReturnsUrlCorrectly(): void
45 {
46 $this->assertSame('http://example.com', $this->templateService->getFileName('http://example.com'));
47 $this->assertSame('https://example.com', $this->templateService->getFileName('https://example.com'));
48 }
49
50 /**
51 * @test
52 */
53 public function getFileNameReturnsFileCorrectly(): void
54 {
55 $this->assertSame('typo3/index.php', $this->templateService->getFileName('typo3/index.php'));
56 }
57
58 /**
59 * @test
60 */
61 public function getFileNameReturnsNullIfDirectory(): void
62 {
63 $this->assertNull($this->templateService->getFileName(__DIR__));
64 }
65
66 /**
67 * @test
68 */
69 public function getFileNameReturnsNullWithInvalidFileName(): void
70 {
71 $this->assertNull($this->templateService->getFileName(' '));
72 $this->assertNull($this->templateService->getFileName('something/../else'));
73 }
74 }