[TASK] Deprecate $GLOBALS['TYPO3_LOADED_EXT']
[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\Package\PackageManager;
21 use TYPO3\CMS\Core\TypoScript\TemplateService;
22 use TYPO3\TestingFramework\Core\Unit\UnitTestCase;
23
24 /**
25 * Test case
26 */
27 class TemplateServiceTest extends UnitTestCase
28 {
29 /**
30 * @var TemplateService
31 */
32 protected $templateService;
33
34 /**
35 * Set up
36 */
37 protected function setUp(): void
38 {
39 $packageManagerProphecy = $this->prophesize(PackageManager::class);
40 $this->templateService = new TemplateService(new Context(), $packageManagerProphecy->reveal());
41 }
42
43 /**
44 * @test
45 */
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
52 /**
53 * @test
54 */
55 public function getFileNameReturnsFileCorrectly(): void
56 {
57 $this->assertSame('typo3/index.php', $this->templateService->getFileName('typo3/index.php'));
58 }
59
60 /**
61 * @test
62 */
63 public function getFileNameReturnsNullIfDirectory(): void
64 {
65 $this->assertNull($this->templateService->getFileName(__DIR__));
66 }
67
68 /**
69 * @test
70 */
71 public function getFileNameReturnsNullWithInvalidFileName(): void
72 {
73 $this->assertNull($this->templateService->getFileName(' '));
74 $this->assertNull($this->templateService->getFileName('something/../else'));
75 }
76 }