Skip to content

Commit

Permalink
Add test
Browse files Browse the repository at this point in the history
  • Loading branch information
lochmueller committed Nov 19, 2024
1 parent 0f1cd50 commit 62523e4
Showing 1 changed file with 55 additions and 0 deletions.
55 changes: 55 additions & 0 deletions Tests/Unit/Cache/Listener/ValidRequestMethodListenerTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
<?php

declare(strict_types=1);

namespace SFC\Staticfilecache\Tests\Unit\Cache\Listener;

use Psr\Http\Message\ServerRequestInterface;
use SFC\Staticfilecache\Cache\Listener\NoBackendUserListener;
use SFC\Staticfilecache\Cache\Listener\ValidRequestMethodListener;
use SFC\Staticfilecache\Event\CacheRuleEvent;
use SFC\Staticfilecache\Event\CacheRuleEventInterface;
use TYPO3\CMS\Core\Authentication\BackendUserAuthentication;
use TYPO3\CMS\Core\Context\Context;
use TYPO3\CMS\Core\Context\UserAspect;

class ValidRequestMethodListenerTest extends AbstractListenerTest
{
public function testNoExplanation(): void
{

$listener = new ValidRequestMethodListener();

$request = $this->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());
}

}

0 comments on commit 62523e4

Please sign in to comment.