diff --git a/Classes/Caching/PageCacheTimeout.php b/Classes/Caching/PageCacheTimeout.php index c396b33..c20dd10 100644 --- a/Classes/Caching/PageCacheTimeout.php +++ b/Classes/Caching/PageCacheTimeout.php @@ -120,7 +120,7 @@ class PageCacheTimeout implements SingletonInterface $newTimeout <= $now || ( $this->timeout instanceof DateTimeImmutable - && $this->timeout >= $newTimeout + && $this->timeout <= $newTimeout ) ) { return; diff --git a/Tests/Functional/Frontend/CacheTest.php b/Tests/Functional/Frontend/CacheTest.php index c1d2068..bdfb4b2 100644 --- a/Tests/Functional/Frontend/CacheTest.php +++ b/Tests/Functional/Frontend/CacheTest.php @@ -174,6 +174,56 @@ class CacheTest extends AbstractTestCase self::assertCacheHeaders($end, $response); } + /** + * @test + */ + public function usesEarliestTimeout(): void + { + $end = (new DateTimeImmutable('now', new DateTimeZone('UTC')))->modify('+2 hours'); + + (new PhpDataSet())->import([ + 'tx_events_domain_model_event' => [ + [ + 'uid' => '1', + 'pid' => '2', + 'title' => 'Test Event 1', + ], + [ + 'uid' => '2', + 'pid' => '2', + 'title' => 'Test Event 2', + ], + ], + 'tx_events_domain_model_date' => [ + [ + 'pid' => '2', + 'event' => '1', + 'start' => $end->format('U'), + 'end' => '0', + ], + [ + 'pid' => '2', + 'event' => '2', + 'start' => $end->modify('+2 hours')->format('U'), + 'end' => '0', + ], + ], + ]); + + $response = $this->executeFrontendRequest($this->getRequestWithSleep([ + 'plugin.' => [ + 'tx_events.' => [ + 'settings.' => [ + 'upcoming' => 1, + ], + ], + ], + ])); + + self::assertSame(200, $response->getStatusCode()); + self::assertCacheHeaders($end, $response); + } + /** * @test */