From 62523e43c6c3a5d1bcbb19018c89837ff4a48aa9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tim=20Lochm=C3=BCller?= Date: Tue, 19 Nov 2024 22:06:03 +0100 Subject: [PATCH] Add test --- .../ValidRequestMethodListenerTest.php | 55 +++++++++++++++++++ 1 file changed, 55 insertions(+) create mode 100644 Tests/Unit/Cache/Listener/ValidRequestMethodListenerTest.php diff --git a/Tests/Unit/Cache/Listener/ValidRequestMethodListenerTest.php b/Tests/Unit/Cache/Listener/ValidRequestMethodListenerTest.php new file mode 100644 index 00000000000..272de272cf5 --- /dev/null +++ b/Tests/Unit/Cache/Listener/ValidRequestMethodListenerTest.php @@ -0,0 +1,55 @@ +getMockBuilder(ServerRequestInterface::class)->getMock(); + $request->method('getMethod')->willReturn('GET'); + + $event = new CacheRuleEvent( + $request, + [], + false + ); + $listener($event); + + self::assertEquals([], $event->getExplanation()); + self::assertEquals(false, $event->isSkipProcessing()); + } + + public function testExplanationAndSkip(): void + { + $listener = new ValidRequestMethodListener(); + + $request = $this->getMockBuilder(ServerRequestInterface::class)->getMock(); + $request->method('getMethod')->willReturn('POST'); + + $event = new CacheRuleEvent( + $request, + [], + false + ); + $listener($event); + + self::assertNotEquals([], $event->getExplanation()); + self::assertEquals(true, $event->isSkipProcessing()); + } + +}