-
-
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
6928b5c
commit 5beaa2b
Showing
4 changed files
with
104 additions
and
1 deletion.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace SFC\Staticfilecache\Tests\Unit\Cache\Listener; | ||
|
||
use Psr\Http\Message\ServerRequestInterface; | ||
use SFC\Staticfilecache\Event\CacheRuleEvent; | ||
use SFC\Staticfilecache\Tests\Unit\AbstractTest; | ||
|
||
abstract class AbstractListenerTest extends AbstractTest | ||
{ | ||
|
||
protected function emptyCacheRuleEvent(): CacheRuleEvent | ||
{ | ||
return new CacheRuleEvent( | ||
$this->getMockBuilder(ServerRequestInterface::class)->getMock(), | ||
[], | ||
false | ||
); | ||
} | ||
|
||
} |
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,37 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace SFC\Staticfilecache\Tests\Unit\Cache\Listener; | ||
|
||
use Psr\Http\Message\ServerRequestInterface; | ||
use SFC\Staticfilecache\Cache\Listener\CachingAllowedListener; | ||
use SFC\Staticfilecache\Event\CacheRuleEvent; | ||
use TYPO3\CMS\Core\Information\Typo3Version; | ||
|
||
class CachingAllowedListenerTest extends AbstractListenerTest | ||
{ | ||
|
||
public function testNoExplanation(): void | ||
{ | ||
$version = $this->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 | ||
); | ||
} | ||
} |
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,43 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace SFC\Staticfilecache\Tests\Unit\Cache\Listener; | ||
|
||
use SFC\Staticfilecache\Cache\Listener\EnableListener; | ||
use SFC\Staticfilecache\Service\ConfigurationService; | ||
|
||
class EnableListenerTest extends AbstractListenerTest | ||
{ | ||
|
||
public function testNoExplanation(): void | ||
{ | ||
$configurationService = $this->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()); | ||
|
||
} | ||
} |
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