laminas/laminas-cache-storage-adapter-test
Test adapter for Laminas Cache storage. Provides a lightweight in-memory storage implementation useful for unit tests and CI, enabling predictable cache behavior without external services or persistent backends.
Illuminate/Cache), it internally relies on PSR-6/PSR-16 adapters (e.g., predis/predis, symfony/cache). This package can be leveraged to test custom cache adapters (e.g., a custom Redis or database-backed cache) in Laravel.Cache facade supports PSR-6/PSR-16 adapters. If a TPM is building a custom cache driver (e.g., for a new database or CDN), this package can validate its compliance.DatabaseCache) for Laravel.AbstractCacheItemPoolIntegrationTest or AbstractSimpleCacheIntegrationTest to ensure their implementation meets PSR standards.getItem(), getMultiple()).hasItem() behavior).clear()).Cache facade has Laravel-specific methods (e.g., forever(), remember()), which aren’t covered here. This package focuses on PSR compliance, not Laravel’s extensions.| Risk Area | Assessment |
|---|---|
| Version Mismatch | Package supports Laminas Cache v4+ and PSR-16 v2/v3. Laravel’s default cache stack (e.g., predis/predis) may not align perfectly. Test for compatibility. |
| False Positives | Some tests (e.g., testHasItemReturnsFalseWhenDeferredItemIsExpired) may not reflect Laravel’s behavior. Validate against actual Laravel cache tests. |
| Overhead | Adding this to a Laravel project adds ~50 test classes. Only useful if building custom adapters. |
| Maintenance Burden | If Laravel’s cache stack evolves (e.g., new PSR-6 methods), this package may lag. Monitor Laminas releases. |
remember())? If yes, supplement with Laravel’s built-in tests.phpunit v10 vs. Laravel’s v9)?| Component | Fit Level | Notes |
|---|---|---|
| Laravel Cache | Medium | Works for PSR-6/PSR-16 adapters but not Laravel-specific features. |
| Custom Cache Drivers | High | Ideal for validating new adapters (e.g., DatabaseCache, S3Cache). |
| Laravel Facade | Low | No direct support for Cache::remember() or tagged caching. |
| PHPUnit | High | Designed for PHPUnit 10+. Laravel’s default PHPUnit may need updates. |
| CI/CD Pipelines | Medium | Adds test coverage but may slow down pipelines if not optimized. |
RedisCache, Laravel already tests it—no need for this.AbstractCacheItemPoolIntegrationTest.AbstractSimpleCacheIntegrationTest.tests/Feature/Caching/ or a new tests/Unit/Cache/ directory.use Laminas\Cache\Storage\Adapter\Test\AbstractCacheItemPoolIntegrationTest;
class DatabaseCacheTest extends AbstractCacheItemPoolIntegrationTest {
protected function createCachePool(): CacheItemPoolInterface {
return new DatabaseCache();
}
}
phpunit.php supports PHPUnit 10+ (required by this package).<phpunit bootstrap="vendor/autoload.php">
<extensions>
<extension class="Laminas\Cache\Storage\Adapter\Test\Extension\CacheTestExtension"/>
</extensions>
</phpunit>
.github/workflows/tests.yml:
- name: Run Cache Tests
run: php vendor/bin/phpunit tests/Unit/Cache/
| Dependency | Laravel Default | Package Requirement | Action Required |
|---|---|---|---|
phpunit/phpunit |
v9.x | v10.x | Upgrade PHPUnit or use a separate test suite. |
laminas/laminas-cache |
Not used | v4.x | Only needed if testing custom adapters. |
psr/cache |
v1.x | v2.x/v3.x | Ensure custom adapters support PSR-6 v2. |
DatabaseCache).| Task | Effort | Owner | Notes |
|---|---|---|---|
| Dependency Updates | Low | DevOps/TPM | Watch for phpunit/laminas-cache updates. |
| Test Updates | Medium | Backend Engineer | If PSR-6 standards change, update tests. |
| Laravel-Specific Gaps | High | TPM | May need to write custom tests for Laravel features. |
| CI/CD Maintenance | Low | DevOps | Add/remove test suites as needed. |
Cache::forever()). Requires familiarity with both Laravel and PSR-6.|
How can I help you explore Laravel packages today?