| name | phpunit-best-practices |
| description | PHPUnit testing best practices and conventions guide. This skill should be used when writing, reviewing, or refactoring PHPUnit tests to ensure consistent, maintainable, and effective test suites. Triggers on tasks involving test creation, test refactoring, test configuration, code coverage, data providers, mocking, or PHPUnit XML configuration. |
| license | MIT |
| metadata | {"author":"pentiminax","version":"1.0.0"} |
PHPUnit Best Practices
Comprehensive testing best practices guide for PHPUnit applications, maintained by pentiminax. Contains 40 rules across 8 categories, prioritized by impact to guide automated test generation, refactoring, and code review.
When to Apply
Reference these guidelines when:
- Writing new PHPUnit test classes or test methods
- Reviewing test code for quality and consistency
- Refactoring existing test suites
- Configuring PHPUnit XML settings
- Setting up code coverage and test organization
Rule Categories by Priority
| Priority | Category | Impact | Prefix |
|---|
| 1 | Principles & Patterns | CRITICAL | principle- |
| 2 | Coding Standards | CRITICAL | standard- |
| 3 | Test Attributes | HIGH | attr- |
| 4 | Data Management | HIGH | data- |
| 5 | Test Documentation | MEDIUM | doc- |
| 6 | Mocking | MEDIUM | mock- |
| 7 | Integration Testing | MEDIUM | integration- |
| 8 | Configuration | LOW-MEDIUM | config- |
Quick Reference
1. Principles & Patterns (CRITICAL)
2. Coding Standards (CRITICAL)
3. Test Attributes (HIGH)
4. Data Management (HIGH)
5. Test Documentation (MEDIUM)
6. Mocking (MEDIUM)
7. Integration Testing (MEDIUM)
8. Configuration (LOW-MEDIUM)
How to Use
Read individual rule files for detailed explanations and code examples:
Each rule file contains:
- Brief explanation of why it matters
- Incorrect code example with explanation
- Correct code example with explanation
- Additional context and references