GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — GitHub - php-cache/integration-tests: Integration tests for your PSR-6 cache implementation

BranchesTags
Open more actions menu

Latest commit

 

History

170 Commits
170 Commits

Folders and files

NameName
Last commit message
Last commit date
.github/workflows
.github/workflows
 
 
src
src
 
 
tests
tests
 
 
tools
tools
 
 
.gitignore
.gitignore
 
 
.php-cs-fixer.dist.php
.php-cs-fixer.dist.php
 
 
LICENSE
LICENSE
 
 
README.md
README.md
 
 
composer.json
composer.json
 
 
phpstan.neon
phpstan.neon
 
 
phpunit.xml.dist
phpunit.xml.dist
 
 

Repository files navigation

PSR-6 and PSR-16 integration tests

CI Latest Stable Version Software License

This package tests whether cache implementations follow PSR-6 or PSR-16. It also includes suites for PHP Cache tags and hierarchical keys.

Version 1 requires PHP 8.2, PHPUnit 11.5 or 12, psr/cache 3, psr/simple-cache 2 or 3, and cache/tag-interop 2.

Installation

composer require --dev cache/integration-tests:^1.0

Testing a PSR-6 pool

Extend CachePoolTest and return a fresh pool from createCachePool():

use Cache\IntegrationTests\CachePoolTest;
use Psr\Cache\CacheItemPoolInterface;

final class PoolIntegrationTest extends CachePoolTest
{
    public function createCachePool(): CacheItemPoolInterface
    {
        return new MyCachePool();
    }
}

Use HierarchicalCachePoolTest for pools that support hierarchical keys.

Testing tags

use Cache\IntegrationTests\TaggableCachePoolTest;
use Cache\TagInterop\TaggableCacheItemPoolInterface;

final class TagIntegrationTest extends TaggableCachePoolTest
{
    public function createCachePool(): TaggableCacheItemPoolInterface
    {
        return new MyTaggableCachePool();
    }
}

Testing a PSR-16 cache

use Cache\IntegrationTests\SimpleCacheTest;
use Psr\SimpleCache\CacheInterface;

final class SimpleCacheIntegrationTest extends SimpleCacheTest
{
    public function createSimpleCache(): CacheInterface
    {
        return new MySimpleCache();
    }
}

Skipping unsupported behavior

The test bases expose a typed $skippedTests map. Skip a test only when the storage backend cannot provide that behavior.

use Cache\IntegrationTests\CachePoolTest;
use Psr\Cache\CacheItemPoolInterface;

final class PoolWithSkippedExpirationTest extends CachePoolTest
{
    /** @var array<string, string> */
    protected array $skippedTests = [
        'testExpiration' => 'This backend does not support expiration.',
    ];

    public function createCachePool(): CacheItemPoolInterface
    {
        return new MyCachePool();
    }
}

Contributing

Run the complete local checks before opening a pull request:

composer test
composer coverage
composer analyse
composer cs-check

Report problems on the GitHub issue tracker.

About

Integration tests for your PSR-6 cache implementation

www.php-cache.com

Resources

Readme
MIT license
Activity
Custom properties

Stars

41 stars

Watchers

7 watching

Forks

36 forks
Report repository

Releases

Packages

Used by

Contributors

Languages

You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.