-
-
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
1f22a3b
commit 46d3741
Showing
9 changed files
with
167 additions
and
4 deletions.
There are no files selected for viewing
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
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
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
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
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
31 changes: 31 additions & 0 deletions
31
Tests/Unit/Cache/Listener/ForceStaticCacheListenerTest.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,31 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace SFC\Staticfilecache\Tests\Unit\Cache\Listener; | ||
|
||
use Psr\Http\Message\ServerRequestInterface; | ||
use SFC\Staticfilecache\Cache\Listener\ForceStaticCacheListener; | ||
use SFC\Staticfilecache\Event\CacheRuleEvent; | ||
use TYPO3\CMS\Core\EventDispatcher\NoopEventDispatcher; | ||
|
||
class ForceStaticCacheListenerTest extends AbstractListenerTest | ||
{ | ||
public function testNoExplanation(): void | ||
{ | ||
$listener = new ForceStaticCacheListener(new NoopEventDispatcher()); | ||
|
||
$cacheRuleEvent = new CacheRuleEvent( | ||
$this->getMockBuilder(ServerRequestInterface::class)->getMock(), | ||
['dummy'], | ||
false | ||
); | ||
|
||
$listener($cacheRuleEvent); | ||
|
||
self::assertEquals(['dummy'], $cacheRuleEvent->getExplanation()); | ||
self::assertEquals(false, $cacheRuleEvent->isSkipProcessing()); | ||
|
||
} | ||
|
||
} |
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,42 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace SFC\Staticfilecache\Tests\Unit\Cache\Listener; | ||
|
||
use Psr\Http\Message\ServerRequestInterface; | ||
use SFC\Staticfilecache\Cache\Listener\NoAuthorizationListener; | ||
use SFC\Staticfilecache\Event\CacheRuleEvent; | ||
|
||
class NoAuthorizationListenerTest extends AbstractListenerTest | ||
{ | ||
public function testNoExplanation(): void | ||
{ | ||
$listener = new NoAuthorizationListener(); | ||
|
||
$event = $this->emptyCacheRuleEvent(); | ||
$listener($event); | ||
|
||
self::assertEquals([], $event->getExplanation()); | ||
self::assertEquals(false, $event->isSkipProcessing()); | ||
} | ||
|
||
|
||
public function testAddExplanation(): void | ||
{ | ||
$listener = new NoAuthorizationListener(); | ||
|
||
$request = $this->getMockBuilder(ServerRequestInterface::class)->getMock(); | ||
$request->method('getHeaderLine')->willReturn('Content'); | ||
|
||
$event = new CacheRuleEvent( | ||
$request, | ||
[], | ||
false | ||
); | ||
$listener($event); | ||
|
||
self::assertNotEquals([], $event->getExplanation()); | ||
self::assertEquals(true, $event->isSkipProcessing()); | ||
} | ||
} |
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,50 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace SFC\Staticfilecache\Tests\Unit\Cache\Listener; | ||
|
||
use SFC\Staticfilecache\Cache\Listener\NoBackendUserListener; | ||
use TYPO3\CMS\Core\Authentication\BackendUserAuthentication; | ||
use TYPO3\CMS\Core\Context\Context; | ||
use TYPO3\CMS\Core\Context\UserAspect; | ||
|
||
class NoBackendUserListenerTest extends AbstractListenerTest | ||
{ | ||
public function testNoExplanation(): void | ||
{ | ||
$userAuth = new BackendUserAuthentication(); | ||
|
||
$userAspect = new UserAspect($userAuth); | ||
|
||
$context = new Context(); | ||
$context->setAspect('backend.user', $userAspect); | ||
|
||
$listener = new NoBackendUserListener($context); | ||
|
||
$event = $this->emptyCacheRuleEvent(); | ||
$listener($event); | ||
|
||
self::assertEquals([], $event->getExplanation()); | ||
self::assertEquals(false, $event->isSkipProcessing()); | ||
} | ||
|
||
public function testExplanationAndSkip(): void | ||
{ | ||
$userAuth = new BackendUserAuthentication(); | ||
$userAuth->user = ['uid' => 5]; | ||
|
||
$userAspect = new UserAspect($userAuth); | ||
|
||
$context = new Context(); | ||
$context->setAspect('backend.user', $userAspect); | ||
|
||
$listener = new NoBackendUserListener($context); | ||
|
||
$event = $this->emptyCacheRuleEvent(); | ||
$listener($event); | ||
|
||
self::assertNotEquals([], $event->getExplanation()); | ||
self::assertEquals(true, $event->isSkipProcessing()); | ||
} | ||
} |
41 changes: 41 additions & 0 deletions
41
Tests/Unit/Cache/Listener/NoWorkspacePreviewListenerTest.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,41 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace SFC\Staticfilecache\Tests\Unit\Cache\Listener; | ||
|
||
use SFC\Staticfilecache\Cache\Listener\NoWorkspacePreviewListener; | ||
use TYPO3\CMS\Core\Context\Context; | ||
use TYPO3\CMS\Core\Context\WorkspaceAspect; | ||
|
||
class NoWorkspacePreviewListenerTest extends AbstractListenerTest | ||
{ | ||
public function testNoExplanation(): void | ||
{ | ||
$context = new Context(); | ||
$context->setAspect('workspace', new WorkspaceAspect(0)); | ||
|
||
$listener = new NoWorkspacePreviewListener($context); | ||
|
||
$event = $this->emptyCacheRuleEvent(); | ||
$listener($event); | ||
|
||
self::assertEquals([], $event->getExplanation()); | ||
self::assertEquals(false, $event->isSkipProcessing()); | ||
} | ||
|
||
public function testExplanationAndSkip(): void | ||
{ | ||
$context = new Context(); | ||
$context->setAspect('workspace', new WorkspaceAspect(1)); | ||
|
||
$listener = new NoWorkspacePreviewListener($context); | ||
|
||
$event = $this->emptyCacheRuleEvent(); | ||
$listener($event); | ||
|
||
self::assertNotEquals([], $event->getExplanation()); | ||
} | ||
|
||
|
||
} |