[TASK] Centralize sys_domain resolving
[Packages/TYPO3.CMS.git] / typo3 / sysext / frontend / Tests / Functional / Controller / TypoScriptFrontendControllerTest.php
1 <?php
2 namespace TYPO3\CMS\Frontend\Tests\Functional\Controller;
3
4 /*
5 * This file is part of the TYPO3 CMS project.
6 *
7 * It is free software; you can redistribute it and/or modify it under
8 * the terms of the GNU General Public License, either version 2
9 * of the License, or any later version.
10 *
11 * For the full copyright and license information, please read the
12 * LICENSE.txt file that was distributed with this source code.
13 *
14 * The TYPO3 project - inspiring people to share!
15 */
16
17 use TYPO3\CMS\Frontend\Controller\TypoScriptFrontendController;
18 use TYPO3\TestingFramework\Core\Functional\FunctionalTestCase;
19
20 /**
21 * Test case
22 */
23 class TypoScriptFrontendControllerTest extends FunctionalTestCase
24 {
25 /**
26 * @var TypoScriptFrontendController
27 */
28 protected $tsFrontendController;
29
30 protected function setUp()
31 {
32 parent::setUp();
33 $this->importDataSet(__DIR__ . '/fixtures.xml');
34
35 $this->tsFrontendController = $this->getAccessibleMock(
36 TypoScriptFrontendController::class,
37 ['dummy'],
38 [],
39 '',
40 false
41 );
42
43 $pageContextMock = $this->getMockBuilder(\TYPO3\CMS\Frontend\Page\PageRepository::class)->getMock();
44 $this->tsFrontendController->_set('sys_page', $pageContextMock);
45 }
46
47 /**
48 * @test
49 */
50 public function getFirstTimeValueForRecordReturnCorrectData()
51 {
52 $this->assertSame(
53 $this->getFirstTimeValueForRecordCall('tt_content:2', 1),
54 2,
55 'The next start/endtime should be 2'
56 );
57 $this->assertSame(
58 $this->getFirstTimeValueForRecordCall('tt_content:2', 2),
59 3,
60 'The next start/endtime should be 3'
61 );
62 $this->assertSame(
63 $this->getFirstTimeValueForRecordCall('tt_content:2', 4),
64 5,
65 'The next start/endtime should be 5'
66 );
67 $this->assertSame(
68 $this->getFirstTimeValueForRecordCall('tt_content:2', 5),
69 PHP_INT_MAX,
70 'The next start/endtime should be PHP_INT_MAX as there are no more'
71 );
72 $this->assertSame(
73 $this->getFirstTimeValueForRecordCall('tt_content:3', 1),
74 PHP_INT_MAX,
75 'Should be PHP_INT_MAX as table has not this PID'
76 );
77 $this->assertSame(
78 $this->getFirstTimeValueForRecordCall('fe_groups:2', 1),
79 PHP_INT_MAX,
80 'Should be PHP_INT_MAX as table fe_groups has no start/endtime in TCA'
81 );
82 }
83
84 /**
85 * @param string $tablePid
86 * @param int $now
87 * @return int
88 */
89 public function getFirstTimeValueForRecordCall($tablePid, $now)
90 {
91 return $this->tsFrontendController->_call('getFirstTimeValueForRecord', $tablePid, $now);
92 }
93 }