diff --git a/CLAUDE.md b/CLAUDE.md index 063788c..6d653b3 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -10,10 +10,10 @@ This file provides guidance to Claude Code (claude.ai/code) when working with co - Install deps: `composer install` - Run tests: `composer test` or `vendor/bin/phpunit` -- Run a single test file: `vendor/bin/phpunit src/tests/CachedStubRepositoryTest.php` -- Run a single test method: `vendor/bin/phpunit --filter testMethodName src/tests/CachedStubRepositoryTest.php` +- Run a single test file: `vendor/bin/phpunit tests/CachedStubRepositoryTest.php` +- Run a single test method: `vendor/bin/phpunit --filter testMethodName tests/CachedStubRepositoryTest.php` -PHPUnit ^11 is used (PHPUnit 12 also allowed); test bootstrap is `vendor/autoload.php`, and the suite lives under `src/tests/` (configured in `phpunit.xml`). The Laravel-integrating tests rely on Orchestra Testbench to boot a minimal Laravel app, register `Trm42\CacheDecorator\ServiceProvider`, and supply the `Cache` / `Config` facades. +PHPUnit ^11 is used (PHPUnit 12 also allowed); test bootstrap is `vendor/autoload.php`, and the suite lives under `tests/` (configured in `phpunit.xml`). The Laravel-integrating tests rely on Orchestra Testbench to boot a minimal Laravel app, register `Trm42\CacheDecorator\ServiceProvider`, and supply the `Cache` / `Config` facades. ## Architecture @@ -38,4 +38,4 @@ The classes use Laravel facades (`Cache`, `Config`, `Log` from `Illuminate\Suppo - Inside custom method overrides, reference the inner object as `$this->decorated`. - To customize caching for a single method, override it in the subclass and use the protected helpers `generateCacheKey()`, `getCache()`, `putCache()` (see README example). - TTL values throughout (subclass `$ttl`, `cache_decorator.ttl` / `repository_cache.ttl` config, calls to `ttl()`) are in seconds — this changed from "minutes" when upgrading from the Laravel 5.x line. -- **Keep the README in sync.** Any `src/` change that affects the main classes (`CacheDecorator`, `RepositoryCacheDecorator`, `ServiceProvider`) and their public-facing surface — property types/signatures, subclassing conventions, config keys, the `__call` flow, or anything a user copy-pastes from a usage example — must be documented in `README.md` as part of the same change. This is a core part of the package's DX and ease of use: the README usage examples should compile and run cleanly against the current code and follow the same conventions as the test stubs under `src/tests/Stubs/`. +- **Keep the README in sync.** Any `src/` change that affects the main classes (`CacheDecorator`, `RepositoryCacheDecorator`, `ServiceProvider`) and their public-facing surface — property types/signatures, subclassing conventions, config keys, the `__call` flow, or anything a user copy-pastes from a usage example — must be documented in `README.md` as part of the same change. This is a core part of the package's DX and ease of use: the README usage examples should compile and run cleanly against the current code and follow the same conventions as the test stubs under `tests/Stubs/`. diff --git a/composer.json b/composer.json index a3b65d9..5e7f4e1 100644 --- a/composer.json +++ b/composer.json @@ -32,7 +32,7 @@ }, "autoload-dev": { "psr-4": { - "Trm42\\CacheDecorator\\Tests\\": "src/tests/" + "Trm42\\CacheDecorator\\Tests\\": "tests/" } }, "extra": { diff --git a/phpunit.xml b/phpunit.xml index 7aa369f..ae68434 100644 --- a/phpunit.xml +++ b/phpunit.xml @@ -10,16 +10,13 @@ cacheDirectory=".phpunit.cache"> - ./src/tests + ./tests ./src - - ./src/tests - diff --git a/src/tests/CachedStubRepositoryTest.php b/tests/CachedStubRepositoryTest.php similarity index 100% rename from src/tests/CachedStubRepositoryTest.php rename to tests/CachedStubRepositoryTest.php diff --git a/src/tests/CachedStubServiceTest.php b/tests/CachedStubServiceTest.php similarity index 100% rename from src/tests/CachedStubServiceTest.php rename to tests/CachedStubServiceTest.php diff --git a/src/tests/StubRepositoryTest.php b/tests/StubRepositoryTest.php similarity index 100% rename from src/tests/StubRepositoryTest.php rename to tests/StubRepositoryTest.php diff --git a/src/tests/Stubs/CachedAutoStubService.php b/tests/Stubs/CachedAutoStubService.php similarity index 100% rename from src/tests/Stubs/CachedAutoStubService.php rename to tests/Stubs/CachedAutoStubService.php diff --git a/src/tests/Stubs/CachedFluentService.php b/tests/Stubs/CachedFluentService.php similarity index 100% rename from src/tests/Stubs/CachedFluentService.php rename to tests/Stubs/CachedFluentService.php diff --git a/src/tests/Stubs/CachedMagicService.php b/tests/Stubs/CachedMagicService.php similarity index 100% rename from src/tests/Stubs/CachedMagicService.php rename to tests/Stubs/CachedMagicService.php diff --git a/src/tests/Stubs/CachedStubRepository.php b/tests/Stubs/CachedStubRepository.php similarity index 100% rename from src/tests/Stubs/CachedStubRepository.php rename to tests/Stubs/CachedStubRepository.php diff --git a/src/tests/Stubs/CachedStubService.php b/tests/Stubs/CachedStubService.php similarity index 100% rename from src/tests/Stubs/CachedStubService.php rename to tests/Stubs/CachedStubService.php diff --git a/src/tests/Stubs/CachedStubServiceWithDependency.php b/tests/Stubs/CachedStubServiceWithDependency.php similarity index 100% rename from src/tests/Stubs/CachedStubServiceWithDependency.php rename to tests/Stubs/CachedStubServiceWithDependency.php diff --git a/src/tests/Stubs/FluentServiceContract.php b/tests/Stubs/FluentServiceContract.php similarity index 100% rename from src/tests/Stubs/FluentServiceContract.php rename to tests/Stubs/FluentServiceContract.php diff --git a/src/tests/Stubs/StubCollaborator.php b/tests/Stubs/StubCollaborator.php similarity index 100% rename from src/tests/Stubs/StubCollaborator.php rename to tests/Stubs/StubCollaborator.php diff --git a/src/tests/Stubs/StubFluentService.php b/tests/Stubs/StubFluentService.php similarity index 100% rename from src/tests/Stubs/StubFluentService.php rename to tests/Stubs/StubFluentService.php diff --git a/src/tests/Stubs/StubMagicService.php b/tests/Stubs/StubMagicService.php similarity index 100% rename from src/tests/Stubs/StubMagicService.php rename to tests/Stubs/StubMagicService.php diff --git a/src/tests/Stubs/StubModel.php b/tests/Stubs/StubModel.php similarity index 100% rename from src/tests/Stubs/StubModel.php rename to tests/Stubs/StubModel.php diff --git a/src/tests/Stubs/StubRepository.php b/tests/Stubs/StubRepository.php similarity index 100% rename from src/tests/Stubs/StubRepository.php rename to tests/Stubs/StubRepository.php diff --git a/src/tests/Stubs/StubService.php b/tests/Stubs/StubService.php similarity index 100% rename from src/tests/Stubs/StubService.php rename to tests/Stubs/StubService.php diff --git a/src/tests/Stubs/StubServiceWithDependency.php b/tests/Stubs/StubServiceWithDependency.php similarity index 100% rename from src/tests/Stubs/StubServiceWithDependency.php rename to tests/Stubs/StubServiceWithDependency.php