php-testing

Write and configure PHPUnit 12 or Pest 4 tests for framework-agnostic PHP projects.

1|Updated Jul 29, 2026
One-click install
npx skills add https://github.com/fusengine/kimi-code --skill php-testing-fusengine
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: php-testing
Source: https://github.com/fusengine/kimi-code/tree/main/plugins/php-expert/skills/php-testing
Command: npx skills add https://github.com/fusengine/kimi-code --skill php-testing-fusengine

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve? Choosing between PHPUnit 12 and Pest 4 and configuring them correctly on a non-Laravel PHP project is error-prone, especially after PHPUnit 12 removed docblock annotations and changed test-double behavior. This Skill provides a decision matrix, migration guidance, and ready-to-use configuration templates so tests are set up correctly the first time. ## Core Features & Use Cases - Framework Decision Matrix: Compares PHPUnit 12 (class-based, enterprise baseline) versus Pest 4 (closure-based, browser/architecture/mutation testing) with honest guidance based on team and CI constraints. - PHPUnit 12 Migration Guidance: Maps removed docblock annotations (@test, @dataProvider, @covers) to PHP 8 attributes and flags breaking changes like static-only data providers and non-configurable createStub(). - Ready-to-Use Templates: Ships phpunit.xml, Pest.php setup, and test-double (stubs, mocks, fixtures, coverage) templates for immediate project scaffolding. - Use Case: You inherit a PHP 8.3 library with no tests. Use this Skill to pick Pest 4 for its expressive syntax, generate the Pest.php and phpunit.xml config, and write your first dataset-driven tests with a coverage gate in CI. ## Quick Start Ask the agent to set up a PHPUnit 12 or Pest 4 test suite with configuration and a first passing test for your non-Laravel PHP project.

Frequently Asked Questions about php-testing

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

FAQPage Schema
How do I choose between PHPUnit and Pest for a PHP project?▼

Choose PHPUnit 12 for enterprise or CI-heavy teams needing explicit, widely supported tests, and Pest 4 for greenfield projects wanting expressive syntax plus built-in browser, architecture, and mutation testing. Both run on the same engine and require PHP 8.3+, so the choice is about team ergonomics, not capability.

How do I migrate PHPUnit annotations to attributes in PHPUnit 12?▼

Replace docblock annotations with PHP 8 attributes: @test becomes #[Test], @dataProvider becomes #[DataProvider('method')], and @covers becomes #[CoversClass(Foo::class)]. Run Rector's PHPUnit set to automate the bulk conversion, and make data providers public static since non-static providers no longer work.

Does Pest 4 work without Laravel?▼

Yes, Pest 4 is framework-agnostic and works on any PHP 8.3+ project. Install it with composer require pestphp/pest --dev, run ./vendor/bin/pest --init to create Pest.php, and remove phpunit/phpunit since Pest brings its own runner.

Why can't I set expectations on createStub() in PHPUnit 12?▼

PHPUnit 12 removed the ability to configure expectations on stubs; createStub() only returns canned values. Use createMock() when you need to verify interactions with ->expects(), and reserve createStub() for dependencies that simply feed data to the code under test.

When should I not use this PHP testing skill?▼

Do not use it for Laravel-specific test helpers like RefreshDatabase or HTTP testing, which belong to the laravel-testing skill, or for static analysis and formatting tooling, which is covered by php-quality-tooling. It targets framework-agnostic PHP projects only.