/woocommerce-commerce:php-testingfrom woocommerce-commerce
Write PHP tests with PHPUnit — unit tests, mocking, data providers, assertions, test doubles, and TDD workflow. Use when writing tests for WooCommerce extensions or PHP projects.
Ships in woocommerce-commerce. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
None: SKILL.md is the whole skill.
Fetch live docs: Web-search site:phpunit.de documentation for the latest PHPUnit documentation. Check https://phpunit.de/ for current version and features.
PHPUnit\Framework\TestCase (or WC_Unit_Test_Case for WooCommerce)test or annotated with #[Test]setUp() — runs before each testtearDown() — runs after each testsetUpBeforeClass() / tearDownAfterClass() — run once per classCore assertions:
assertEquals( $expected, $actual ) — loose equalityassertSame( $expected, $actual ) — strict identityassertTrue( $condition ) / assertFalse( $condition )assertNull( $value ) / assertNotNull( $value )assertCount( $expected, $array )assertContains( $needle, $haystack )assertInstanceOf( $class, $object )assertArrayHasKey( $key, $array )assertStringContainsString( $needle, $haystack )$this->expectException( InvalidArgumentException::class )$this->expectExceptionMessage( 'Expected message' )$this->expectExceptionCode( 404 )Create mock objects to verify interactions:
$mock = $this->createMock( PaymentProcessor::class );
$mock->expects( $this->once() )
->method( 'charge' )
->with( $this->equalTo( 29.99 ) )
->willReturn( true );
Return predetermined values without verifying calls:
$stub = $this->createStub( PriceCalculator::class );
$stub->method( 'calculate' )->willReturn( 29.99 );
$this->once() — called exactly once$this->exactly( $n ) — called exactly n times$this->never() — not called$this->atLeastOnce() — called one or more times$this->any() — any number of callswillReturn( $value ) — return fixed valuewillReturnMap( $map ) — return based on argumentswillReturnCallback( $callable ) — custom logicwillThrowException( $exception ) — throw on callSupply multiple test cases to a single test method:
public static function priceProvider(): array {
return [
'regular price' => [ 29.99, 29.99, '' ],
'sale price' => [ 29.99, 19.99, '19.99' ],
'zero price' => [ 0.00, 0.00, '' ],
];
}
#[DataProvider('priceProvider')]
public function test_get_display_price( float $regular, float $expected, string $sale ): void {
// test with each data set
}
#[DataProvider('methodName')] attribute$this->factory->post, $this->factory->usergo_to( $url ) — simulate page loadset_current_screen( 'edit-post' ) — simulate admin screenUse WP_Mock or Brain\Monkey libraries:
add_action, add_filter, do_action, apply_filterswp_remote_get, get_option, etc.Filter pre_http_request to intercept wp_remote_get() / wp_remote_post():
add_filter( 'pre_http_request', function( $preempt, $args, $url ) {
return [ 'response' => [ 'code' => 200 ], 'body' => '{"status":"ok"}' ];
}, 10, 3 );
tests/
├── bootstrap.php # Test bootstrap
├── Unit/ # Pure unit tests (no WP)
│ └── PriceCalculatorTest.php
├── Integration/ # Tests with WP/WC loaded
│ ├── ProductTest.php
│ └── OrderTest.php
└── E2E/ # Playwright end-to-end
└── specs/
unit, integrationtest_process_payment_returns_success_for_valid_cardFetch the PHPUnit documentation for exact assertion signatures, mock API, and configuration options before implementing.
What SKILL.md sets; muted values are Claude Code's defaults
20 skills in this plugin
/php-modernWrite modern PHP 8.x code — typed properties, enums, readonly classes, match expressions, named arguments, union/intersection types, fibers, attributes, and constructor promotion. Use when writing PHP for WooCommerce or any PHP 8.x project./php-patternsApply PHP design patterns — Singleton, Factory, Strategy, Observer, Repository, Decorator, and Dependency Injection in PHP. Use when structuring WooCommerce extension code or implementing complex business logic./woo-adminBuild WooCommerce admin interfaces — settings pages, admin menus, product data tabs/panels, order meta boxes, WooCommerce Admin (React analytics), and reports. Use when creating admin-facing configuration or display pages./woo-apiBuild and consume WooCommerce REST API v3 endpoints — authentication, custom endpoints, extending existing resources, webhooks, and batch operations. Use when creating custom API endpoints or integrating external systems with WooCommerce./woo-blocksBuild WooCommerce Blocks — Gutenberg block integration, block-based cart/checkout extensions, Store API, and the @woocommerce/blocks-checkout package. Use when extending the block editor for WooCommerce or customizing block-based checkout/cart./woo-catalogWork with WooCommerce catalog — product types, categories, tags, attributes, product queries, search, related products, and product visibility. Use when managing products programmatically or customizing the catalog display.npx claudepluginhub orcaqubits/agentic-commerce-skills-plugins --plugin woocommerce-commerceOther plugins' skills for the same job