php-testing

Generate PHPUnit test code with data providers, mocks, and verification commands.

415|44|Updated Mar 18, 2026
One-click install
npx skills add https://github.com/notque/vexjoy-agent --skill php-testing-notque
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: php-testing
Source: https://github.com/notque/vexjoy-agent/tree/main/skills/engineering/php-testing
Command: npx skills add https://github.com/notque/vexjoy-agent --skill php-testing-notque

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

Prevents PHP changes from being accepted without evidence by enforcing correct PHPUnit test structure, safe test doubles, proper database isolation, and repeatable verification.

Core Features & Use Cases

  • Unit testing patterns: Uses PHPUnit conventions like TestCase, consistent setup/teardown, and clear assertions.
  • Table-driven test coverage: Encourages @dataProvider to reduce duplication while expanding scenario coverage.
  • Test doubles and database isolation: Guides stubs/mocks/Prophecy usage and recommends rollback-based database strategies.
  • Verification gates: Standardizes how to run PHPUnit and (optionally) enforce coverage thresholds for evidence-based completion.

Quick Start

Ask the AI to write a complete PHPUnit test suite for your PHP class, including mocks or stubs for collaborators, table-driven cases with data providers, and a PHPUnit command to verify the results.

Frequently Asked Questions about php-testing

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I write PHPUnit tests using data providers for table-driven cases?

PHPUnit data providers enable table-driven testing by feeding multiple datasets into a single test method via @dataProvider annotations, reducing duplication while expanding scenario coverage. This strategy ensures PHP changes are validated consistently across varied inputs.

What is the best way to isolate database tests in PHP applications?

Database testing isolation is best achieved using rollback-based strategies within PHPUnit to ensure a deterministic state. Proper setup via parent setUp() and teardown methods guarantees that database test scenarios do not leak data between test executions.

When should I use stubs, mocks, or Prophecy in PHPUnit?

Use stubs, mocks, or Prophecy in PHPUnit to test collaborator behavior without executing real dependencies. You should verify collaborator interactions while avoiding mocking the class under test directly, ensuring your unit logic testing remains isolated.

How do I run PHPUnit and enforce code coverage thresholds?

Run PHPUnit verification using the ./vendor/bin/phpunit command, optionally configuring coverage thresholds to enforce evidence-based completion. This verification gate ensures PHP changes are validated with real test evidence rather than assumptions before acceptance.

Does PHPUnit work with HTTP testing scenarios in common PHP frameworks?

PHPUnit supports HTTP testing scenarios in common PHP frameworks by applying consistent TestCase conventions and assertions. This allows you to verify endpoint behavior and integration logic while maintaining proper test doubles and database isolation.