mcpField
P
phpunit-best-practices

phpunit-best-practices

github.com/pentiminaxTesting & quality2179 installsUpdated 5w ago
Repository

About phpunit-best-practices

phpunit-best-practices is a guidance skill for teams writing, reviewing, and maintaining PHPUnit tests. Its 40 prioritized rules cover test design, coding standards, attributes, data, mocking, integration tests, and configuration.

Key features

  1. 0140 prioritized testing rules
  2. 02Eight rule categories
  3. 03Guidance for test design and standards
  4. 04Advice on attributes, data, and mocking
  5. 05Integration testing and configuration guidance

Use cases

  1. 01Generating PHPUnit tests
  2. 02Reviewing test code quality
  3. 03Refactoring an existing test suite
  4. 04Configuring coverage and test organization

Install

Copy the command and run it in a terminal.

$npx skills add https://github.com/pentiminax/agent-skills --skill phpunit-best-practices

After installing, type/phpunit-best-practicesin Claude Code to confirm it loaded.

Bundled files

References and scripts installed along with SKILL.md.

metadata.json
README.md
rules/
_sections.md
_template.md
attr-covers-class.md
attr-group.md
attr-no-annotations.md
attr-size-categories.md
attr-test-attribute.md
attr-uses-class.md
config-cache.md
config-order-by.md
config-source-coverage.md
config-stop-on-failure.md
config-strictness.md
config-testsuites.md
data-direct-instantiation.md
data-factory-method.md
data-provider-external.md
data-provider.md
data-test-with.md
doc-readable-names.md
doc-testdox-attribute.md
doc-testdox.md
integration-performance.md
integration-singleton.md
integration-smoke-cli.md
integration-smoke-http.md
integration-transactions.md
mock-avoid-over-mocking.md

Details

From the project README

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

PriorityCategoryImpactPrefix
1Principles & PatternsCRITICALprinciple-
2Coding StandardsCRITICALstandard-
3Test AttributesHIGHattr-
4Data ManagementHIGHdata-
5Test DocumentationMEDIUMdoc-
6MockingMEDIUMmock-
7Integration TestingMEDIUMintegration-
8ConfigurationLOW-MEDIUMconfig-

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

Comments

Markdown supported