Help us improve
Share bugs, ideas, or general feedback.
From woocommerce-commerce
Writes PHPUnit tests for PHP projects: unit tests, assertions, mocks, stubs, data providers, exception testing, TDD workflows. Supports WooCommerce via WC_Unit_Test_Case.
npx claudepluginhub orcaqubits/agentic-commerce-skills-plugins --plugin woocommerce-commerceHow this skill is triggered — by the user, by Claude, or both
Slash command
/woocommerce-commerce:php-testingThis skill is limited to the following tools:
The summary Claude sees in its skill listing — used to decide when to auto-load this skill
**Fetch live docs**: Web-search `site:phpunit.de documentation` for the latest PHPUnit documentation. Check `https://phpunit.de/` for current version and features.
Writes PHPUnit tests for PHP code: unit tests, mocking, data providers, test doubles, assertions, and TDD practices. Use for testing PHP apps including Magento.
PHPUnit testing framework conventions and practices. Invoke whenever task involves any interaction with PHPUnit — writing tests, configuring PHPUnit, data providers, mocking, assertions, debugging test failures, or coverage.
Guides WordPress testing strategy using PHPUnit and WP_UnitTestCase, with test categories, coverage targets, and AAA patterns. Use for writing tests, infrastructure setup, or coverage review.
Share bugs, ideas, or general feedback.
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.