From magento2-commerce
Writes PHPUnit tests for PHP code: unit tests, mocking, data providers, test doubles, assertions, and TDD practices. Use for testing PHP apps including Magento.
npx claudepluginhub orcaqubits/agentic-commerce-skills-plugins --plugin magento2-commerceThis skill is limited to using the following tools:
**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.
Generates design tokens/docs from CSS/Tailwind/styled-components codebases, audits visual consistency across 10 dimensions, detects AI slop in UI.
Records polished WebM UI demo videos of web apps using Playwright with cursor overlay, natural pacing, and three-phase scripting. Activates for demo, walkthrough, screen recording, or tutorial requests.
Delivers idiomatic Kotlin patterns for null safety, immutability, sealed classes, coroutines, Flows, extensions, DSL builders, and Gradle DSL. Use when writing, reviewing, refactoring, or designing Kotlin code.
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.