mirror of
https://github.com/DirectoryLister/DirectoryLister.git
synced 2025-08-18 11:51:40 +02:00
Added test for non-pruneable cache adapters
This commit is contained in:
@@ -6,8 +6,7 @@ use App\Middlewares\PruneCacheMiddleware;
|
||||
use PHPUnit\Framework\MockObject\MockObject;
|
||||
use Psr\Http\Message\ServerRequestInterface;
|
||||
use Psr\Http\Server\RequestHandlerInterface;
|
||||
use Symfony\Component\Cache\Adapter\FilesystemAdapter;
|
||||
use Symfony\Component\Cache\Adapter\PhpFilesAdapter;
|
||||
use Symfony\Component\Cache\Adapter;
|
||||
use Symfony\Contracts\Cache\CacheInterface;
|
||||
use Tests\TestCase;
|
||||
|
||||
@@ -34,11 +33,38 @@ class PruneCacheMiddlewareTest extends TestCase
|
||||
);
|
||||
}
|
||||
|
||||
/** @dataProvider nonPruneableCacheAdapters */
|
||||
public function test_it_does_not_prune_the_cache_when_using_a_non_prunable_adapter(string $cacheAdapter): void
|
||||
{
|
||||
/** @var CacheInterface&MockObject */
|
||||
$cache = $this->getMockBuilder($cacheAdapter)
|
||||
->disableOriginalConstructor()
|
||||
->addMethods(['prune'])
|
||||
->getMock();
|
||||
|
||||
$cache->expects($this->never())->method('prune');
|
||||
|
||||
(new PruneCacheMiddleware($this->config, $cache))(
|
||||
$this->createMock(ServerRequestInterface::class),
|
||||
$this->createMock(RequestHandlerInterface::class)
|
||||
);
|
||||
}
|
||||
|
||||
public function pruneableCacheAdapters(): array
|
||||
{
|
||||
return [
|
||||
[FilesystemAdapter::class],
|
||||
[PhpFilesAdapter::class],
|
||||
[Adapter\FilesystemAdapter::class],
|
||||
[Adapter\PhpFilesAdapter::class],
|
||||
];
|
||||
}
|
||||
|
||||
public function nonPruneableCacheAdapters(): array
|
||||
{
|
||||
return [
|
||||
[Adapter\ApcuAdapter::class],
|
||||
[Adapter\ArrayAdapter::class],
|
||||
[Adapter\MemcachedAdapter::class],
|
||||
[Adapter\RedisAdapter::class],
|
||||
];
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user