PHP Testing
**Priority: P1 (HIGH)**
Universal anti-slop rules (identity fixtures, tautologies, skip/focus, mock echoing, bug-first lock, sleeps, shallow
assertions, coverage): anti-slop-rules.md. Only PHP deltas follow.
Stack Deltas
- PHPUnit / Pest: extend
TestCase; organize intoUnit/,Integration/,Feature/; Pest usesit()and
expect().
- Strict assertions:
assertSame(===) overassertEqualsto avoid type coercion; alsoassertCount()and
assertMatchesRegularExpression().
- Data providers (
[BE-TEST-01]):#[DataProvider('statusProvider')](PHPUnit 10+) ordataset(Pest); providers
are static methods returning test-case arrays; equivalent inputs only, distinct scenarios may stay separate.
- Mocking (
[BE-TEST-04]):createMock()for boundaries; tests independent and repeatable; DB tests use transactions
or SQLite :memory:.
- Coverage: diagnostic and project-configured; verify risk-weighted critical paths.
Anti-Patterns
- No private-method tests: test through the public interface only.
- No over-mocking: mock external boundaries, not internals.
- No real network or DB in unit tests: use in-memory databases or mocks.
- No coverage chasing: prioritize meaningful assertions over an arbitrary percentage.