‪TYPO3CMS  ‪main
CacheLifetimeCalculatorTest.php
Go to the documentation of this file.
1 <?php
2 
3 declare(strict_types=1);
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 
19 
20 use PHPUnit\Framework\Attributes\Test;
21 use Psr\EventDispatcher\EventDispatcherInterface;
24 use TYPO3\TestingFramework\Core\Functional\FunctionalTestCase;
25 
26 final class ‪CacheLifetimeCalculatorTest extends FunctionalTestCase
27 {
28  protected function ‪setUp(): void
29  {
30  parent::setUp();
31  $this->importCSVDataSet(__DIR__ . '/fixtures.csv');
32  }
33 
34  #[Test]
36  {
37  $subject = new class ($this->get('cache.core'), $this->get(EventDispatcherInterface::class), $this->get(ConnectionPool::class)) extends ‪CacheLifetimeCalculator {
38  public function getFirstTimeValueForRecord(string $tableDef, int $currentTimestamp): int
39  {
40  return parent::getFirstTimeValueForRecord($tableDef, $currentTimestamp);
41  }
42  };
43 
44  self::assertSame(
45  $subject->getFirstTimeValueForRecord('tt_content:2', 1),
46  2,
47  'The next start/endtime should be 2'
48  );
49  self::assertSame(
50  $subject->getFirstTimeValueForRecord('tt_content:2', 2),
51  3,
52  'The next start/endtime should be 3'
53  );
54  self::assertSame(
55  $subject->getFirstTimeValueForRecord('tt_content:2', 4),
56  5,
57  'The next start/endtime should be 5'
58  );
59  self::assertSame(
60  $subject->getFirstTimeValueForRecord('tt_content:2', 5),
61  PHP_INT_MAX,
62  'The next start/endtime should be PHP_INT_MAX as there are no more'
63  );
64  self::assertSame(
65  $subject->getFirstTimeValueForRecord('tt_content:3', 1),
66  PHP_INT_MAX,
67  'Should be PHP_INT_MAX as table has not this PID'
68  );
69  self::assertSame(
70  $subject->getFirstTimeValueForRecord('fe_groups:2', 1),
71  PHP_INT_MAX,
72  'Should be PHP_INT_MAX as table fe_groups has no start/endtime in TCA'
73  );
74  }
75 }
‪TYPO3\CMS\Frontend\Tests\Functional\Cache\CacheLifetimeCalculatorTest\getFirstTimeValueForRecordReturnCorrectData
‪getFirstTimeValueForRecordReturnCorrectData()
Definition: CacheLifetimeCalculatorTest.php:35
‪TYPO3\CMS\Frontend\Tests\Functional\Cache\CacheLifetimeCalculatorTest
Definition: CacheLifetimeCalculatorTest.php:27
‪TYPO3\CMS\Frontend\Tests\Functional\Cache\CacheLifetimeCalculatorTest\setUp
‪setUp()
Definition: CacheLifetimeCalculatorTest.php:28
‪TYPO3\CMS\Frontend\Cache\CacheLifetimeCalculator
Definition: CacheLifetimeCalculator.php:39
‪TYPO3\CMS\Frontend\Tests\Functional\Cache
Definition: CacheLifetimeCalculatorTest.php:18
‪TYPO3\CMS\Core\Database\ConnectionPool
Definition: ConnectionPool.php:46