- Can I use this package to test Laravel’s built-in cache drivers (Redis, Memcached, file) instead of writing custom tests?
- No, this package is designed for testing custom cache adapters that implement PSR-6 or PSR-16 standards, not Laravel’s built-in drivers. Laravel already provides robust testing for its core cache implementations. Use this only if you’re building a custom adapter (e.g., database-backed cache).
- How do I integrate this into a Laravel project to test a custom cache driver?
- First, ensure your custom driver implements PSR-6 or PSR-16. Then, extend either `AbstractCacheItemPoolIntegrationTest` (for PSR-6) or `AbstractSimpleCacheIntegrationTest` (for PSR-16) in your test class. Run the tests via PHPUnit, and the adapter will validate your implementation against PSR standards.
- Will this package work with Laravel’s `Cache::remember()` or tagged caching features?
- No, this package only tests PSR-6/PSR-16 compliance and does not cover Laravel-specific features like `remember()`, `tags()`, or `forever()`. For those, use Laravel’s built-in cache tests or mock the facade directly in your unit tests.
- Does this package support Laravel 10+ and PHPUnit 10+?
- Yes, the package is compatible with Laminas Cache v4+ and PSR-16 v2/v3, which aligns with Laravel 10’s requirements. However, ensure your project’s PHPUnit version (e.g., v10) matches the package’s dependencies. If conflicts arise, pin versions in `composer.json`.
- How can I simulate cache expiration or failures in my tests?
- The adapter provides deterministic control over cache behavior. Use methods like `setItem()` with a TTL (time-to-live) to test expirations, or manually trigger failures by overriding the adapter’s `save()` or `get()` methods in your test class. Edge cases like invalid keys are also covered in the test suite.
- Is this package suitable for CI/CD pipelines, or will it slow down tests?
- This package is lightweight and in-memory, so it won’t slow down CI pipelines significantly. However, if you’re testing multiple adapters or running extensive test suites, consider optimizing by skipping slow or irrelevant tests. It’s ideal for validating custom adapters in CI.
- Are there alternatives to this package for testing Laravel cache logic?
- For Laravel-specific cache features (e.g., `remember()`, tags), use Laravel’s built-in tests or mock the `Illuminate/Contracts/Cache` facade. For PSR-6/PSR-16 compliance, alternatives include `php-cache/adapter-common` or writing custom mocks with PHPUnit’s `createMock()`. This package is unique for Laminas Cache adapter validation.
- How do I handle version conflicts between this package and Laravel’s dependencies?
- If you encounter conflicts (e.g., PHPUnit version mismatches), explicitly define the required versions in your `composer.json` under `require-dev`. For example, specify `phpunit/phpunit:^10.0` if Laravel uses an older version. Avoid using `^` for strict compatibility.
- Can I use this to test Laravel’s cache facade directly, or only custom adapters?
- This package is for testing custom cache adapters that implement PSR-6/PSR-16, not Laravel’s facade directly. To test the facade, mock the underlying adapter or use Laravel’s `Cache` service provider tests. The facade’s Laravel-specific methods (e.g., `tags()`) are outside this package’s scope.
- What’s the best way to maintain this package in a Laravel project if Laminas Cache updates?
- Monitor Laminas Cache releases for breaking changes. If updates introduce new PSR-6/PSR-16 methods, extend the test classes to cover them. For long-term maintenance, consider forking the package and adapting it to Laravel’s needs, or contribute updates upstream to keep it aligned with PSR standards.