[TASK] typo3/testing-framework now flushes runtime caches
[Packages/TYPO3.CMS.git] / typo3 / sysext / frontend / Tests / UnitDeprecated / Controller / TypoScriptFrontendControllerTest.php
1 <?php
2 declare(strict_types = 1);
3 namespace TYPO3\CMS\Frontend\Tests\UnitDeprecated\Controller;
4
5 /*
6 * This file is part of the TYPO3 CMS project.
7 *
8 * It is free software; you can redistribute it and/or modify it under
9 * the terms of the GNU General Public License, either version 2
10 * of the License, or any later version.
11 *
12 * For the full copyright and license information, please read the
13 * LICENSE.txt file that was distributed with this source code.
14 *
15 * The TYPO3 project - inspiring people to share!
16 */
17
18 use TYPO3\CMS\Frontend\Controller\TypoScriptFrontendController;
19 use TYPO3\TestingFramework\Core\Unit\UnitTestCase;
20
21 /**
22 * Test case
23 */
24 class TypoScriptFrontendControllerTest extends UnitTestCase
25 {
26 /**
27 * @var \PHPUnit_Framework_MockObject_MockObject|\TYPO3\TestingFramework\Core\AccessibleObjectInterface|TypoScriptFrontendController
28 */
29 protected $subject;
30
31 protected function setUp()
32 {
33 parent::setUp();
34 $this->subject = $this->getAccessibleMock(TypoScriptFrontendController::class, ['dummy'], [], '', false);
35 }
36
37 /**
38 * Tests concerning domainNameMatchesCurrentRequest
39 */
40
41 /**
42 * @return array
43 */
44 public function domainNameMatchesCurrentRequestDataProvider()
45 {
46 return [
47 'same domains' => [
48 'typo3.org',
49 'typo3.org',
50 '/index.php',
51 true,
52 ],
53 'same domains with subdomain' => [
54 'www.typo3.org',
55 'www.typo3.org',
56 '/index.php',
57 true,
58 ],
59 'different domains' => [
60 'foo.bar',
61 'typo3.org',
62 '/index.php',
63 false,
64 ],
65 'domain record with script name' => [
66 'typo3.org',
67 'typo3.org/foo/bar',
68 '/foo/bar/index.php',
69 true,
70 ],
71 'domain record with wrong script name' => [
72 'typo3.org',
73 'typo3.org/foo/bar',
74 '/bar/foo/index.php',
75 false,
76 ],
77 ];
78 }
79
80 /**
81 * @param string $currentDomain
82 * @param string $domainRecord
83 * @param string $scriptName
84 * @param bool $expectedResult
85 * @test
86 * @dataProvider domainNameMatchesCurrentRequestDataProvider
87 */
88 public function domainNameMatchesCurrentRequest($currentDomain, $domainRecord, $scriptName, $expectedResult)
89 {
90 $_SERVER['HTTP_HOST'] = $currentDomain;
91 $_SERVER['SCRIPT_NAME'] = $scriptName;
92 $this->assertEquals($expectedResult, $this->subject->domainNameMatchesCurrentRequest($domainRecord));
93 }
94 }