-
-
Notifications
You must be signed in to change notification settings - Fork 65
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
0f1cd50
commit 62523e4
Showing
1 changed file
with
55 additions
and
0 deletions.
There are no files selected for viewing
55 changes: 55 additions & 0 deletions
55
Tests/Unit/Cache/Listener/ValidRequestMethodListenerTest.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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()); | ||
} | ||
|
||
} |