/magento2-commerce:php-testingfrom magento2-commerce
Guides writing PHP tests with PHPUnit — unit tests, mocking, data providers, test doubles, assertions, and TDD practices. Use when writing tests for PHP code.
Ships in magento2-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:docs.phpunit.de phpunit 10 (or current version) for the latest PHPUnit documentation. Check https://phpunit.de/ for current version.
PHPUnit\Framework\TestCasetest or annotated #[Test]setUp() — runs before each testtearDown() — runs after each testsetUpBeforeClass() / tearDownAfterClass() — per-class lifecycleCommon assertions:
assertEquals($expected, $actual) — loose comparisonassertSame($expected, $actual) — strict comparison (type + value)assertTrue($value) / assertFalse($value)assertNull($value) / assertNotNull($value)assertInstanceOf($class, $object)assertCount($count, $array)assertArrayHasKey($key, $array)assertStringContainsString($needle, $haystack)expectException($class) — exception testingSupply multiple test cases to a single test method:
#[DataProvider('providerName')] attribute (PHPUnit 10+)Verify behavior — assert that methods were called with expected arguments:
$this->createMock(SomeClass::class)$mock->expects($this->once())->method('save')->with($entity)$mock->expects($this->never())->method('delete')Provide canned responses — no behavior verification:
$stub->method('getById')->willReturn($entity)$stub->method('getList')->willReturn($searchResults)willReturn($value) — always returns this valuewillReturnMap($map) — returns based on argument mappingwillReturnCallback($callable) — dynamic returnwillThrowException($exception) — throws on callwillReturnSelf() — returns the mock (for fluent APIs)willReturnOnConsecutiveCalls($val1, $val2, $val3) — different return per call.
Note:
willReturnOnConsecutiveCalls()is deprecated in PHPUnit 10.3+. UsewillReturn()with$this->onConsecutiveCalls()orwillReturnCallback()with a counter instead.
$this->expectException(NoSuchEntityException::class);
$this->expectExceptionMessage('Entity not found');
$repository->getById(999);
Don't test private methods directly — test through public methods. If a private method is complex enough to test independently, it should probably be extracted to its own class.
Create the class under test with mocked dependencies:
--coverage-html <dir> — generate HTML coverage report--coverage-text — terminal outputphpunit.xml or phpunit.xml.dist:
testGetByIdThrowsWhenNotFound()setUp() for common test setupFetch PHPUnit docs for exact assertion methods, mock API, and configuration options for your PHPUnit version before writing tests.
What SKILL.md sets; muted values are Claude Code's defaults
19 skills in this plugin
/magento-admin-uiBuild Magento 2 admin interfaces — UI component grids, forms, system configuration, ACL, and admin controllers. Use when creating admin panels, data grids, edit forms, or system settings./magento-apiBuild Magento 2 REST and GraphQL APIs — webapi.xml, schema.graphqls, resolvers, authentication, and ACL. Use when creating custom API endpoints, extending the GraphQL schema, or integrating external systems./magento-catalogWork with Magento 2 catalog — product types, categories, attributes, indexing, and search integration. Use when building catalog features, customizing product types, or working with the catalog architecture./magento-checkoutCustomize Magento 2 checkout — payment methods, shipping carriers, totals collectors, and checkout UI. Use when building custom payment/shipping integrations or modifying the checkout flow./magento-deployDeploy Magento 2 — deployment modes, static content deployment, DI compilation, CLI commands, zero-downtime strategies, and CI/CD pipeline setup. Use when preparing for production deployment or building deployment automation./magento-diConfigure Magento 2 dependency injection — di.xml, types, virtual types, preferences, argument replacement, and Object Manager. Use when wiring dependencies, creating class variations, or configuring module integrations.npx claudepluginhub orcaqubits/agentic-commerce-skills-plugins --plugin magento2-commerceOther plugins' skills for the same job