diff --git a/Tests/Unit/Cache/Listener/AbstractListenerTest.php b/Tests/Unit/Cache/Listener/AbstractListenerTest.php new file mode 100644 index 00000000000..ff8048c03cd --- /dev/null +++ b/Tests/Unit/Cache/Listener/AbstractListenerTest.php @@ -0,0 +1,23 @@ +getMockBuilder(ServerRequestInterface::class)->getMock(), + [], + false + ); + } + +} diff --git a/Tests/Unit/Cache/Listener/CachingAllowedListenerTest.php b/Tests/Unit/Cache/Listener/CachingAllowedListenerTest.php new file mode 100644 index 00000000000..9bd88faa02f --- /dev/null +++ b/Tests/Unit/Cache/Listener/CachingAllowedListenerTest.php @@ -0,0 +1,37 @@ +getMockBuilder(Typo3Version::class)->disableOriginalConstructor()->getMock(); + $version->method('getMajorVersion')->willReturn(12); + + $listener = new CachingAllowedListener($version); + + $event = $this->emptyCacheRuleEvent(); + $listener($event); + + self::assertEquals([], $event->getExplanation()); + self::assertEquals(false, $event->isSkipProcessing()); + + } + protected function emptyCacheRuleEvent(): CacheRuleEvent + { + return new CacheRuleEvent( + $this->getMockBuilder(ServerRequestInterface::class)->getMock(), + [], + false + ); + } +} diff --git a/Tests/Unit/Cache/Listener/EnableListenerTest.php b/Tests/Unit/Cache/Listener/EnableListenerTest.php new file mode 100644 index 00000000000..53aaafb4e34 --- /dev/null +++ b/Tests/Unit/Cache/Listener/EnableListenerTest.php @@ -0,0 +1,43 @@ +getMockBuilder(ConfigurationService::class)->disableOriginalConstructor()->getMock(); + $configurationService->method('isBool')->willReturn(false); + + $listener = new EnableListener($configurationService); + + $event = $this->emptyCacheRuleEvent(); + $listener($event); + + self::assertEquals([], $event->getExplanation()); + self::assertEquals(false, $event->isSkipProcessing()); + + } + + + public function testAddExplanation(): void + { + $configurationService = $this->getMockBuilder(ConfigurationService::class)->disableOriginalConstructor()->getMock(); + $configurationService->method('isBool')->willReturn(true); + + $listener = new EnableListener($configurationService); + + $event = $this->emptyCacheRuleEvent(); + $listener($event); + + self::assertNotEquals([], $event->getExplanation()); + self::assertEquals(false, $event->isSkipProcessing()); + + } +} diff --git a/Tests/UnitTests.xml b/Tests/UnitTests.xml index 09efe93512e..8a6ed925759 100755 --- a/Tests/UnitTests.xml +++ b/Tests/UnitTests.xml @@ -9,8 +9,8 @@ Unit/ Unit/AbstractTest.php - Unit/Cache/Rule/AbstractRuleTest.php Unit/Service/HttpPush/AbstractHttpPushTest.php + Unit/Cache/Listener/AbstractListenerTest.php