Problem
Some unit tests are tightly coupled to private implementation details by invoking private methods through reflection.
Current hotspots
- tests/Unit/Collector/DoctrineDoctorDataCollectorTest.php
- invokes private methods: filterQueriesByPaths, isQueryFromExcludedPaths
- tests/Unit/DependencyInjection/DoctrineDoctorExtensionTest.php
- invokes private method: classNameToConfigKey
These tests are brittle: harmless internal refactors (renaming/moving private methods) can break tests even when public behavior is unchanged.
Why refactor
- Preserve refactorability of internals
- Keep tests focused on observable behavior
- Reduce maintenance cost and false failures
Proposed approach
- Replace private-method reflection tests with public-contract tests wherever possible.
- For complex pure logic currently hidden in private methods, extract dedicated collaborators and test them directly (without reflection), for example:
- query path filtering logic from DoctrineDoctorDataCollector
- analyzer config key formatting logic from DoctrineDoctorExtension
- Keep DoctrineDoctorDataCollector / DoctrineDoctorExtension tests at integration-of-collaborators level (public API only).
Acceptance criteria
- No test uses reflection to invoke private methods in these areas.
- Equivalent behavior coverage is preserved or improved.
- Existing public behavior remains unchanged.
- Test suite remains green (phpunit, phpstan, ecs).
Notes
This issue is intentionally scoped to tests coupled to private methods. Other test quality improvements can be tracked separately.
Problem
Some unit tests are tightly coupled to private implementation details by invoking private methods through reflection.
Current hotspots
These tests are brittle: harmless internal refactors (renaming/moving private methods) can break tests even when public behavior is unchanged.
Why refactor
Proposed approach
Acceptance criteria
Notes
This issue is intentionally scoped to tests coupled to private methods. Other test quality improvements can be tracked separately.