No slash command · from test-writing
Generates Shopware-compliant PHPUnit unit tests with PHPStan validation. Handles coverage exclusions, test requirement analysis, and structured test generation.
Ships in test-writing. 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.
Read when SKILL.md points to them.
Generate Shopware-compliant PHPUnit unit tests that pass PHPStan and PHPUnit validation.
Write ONLY to:
tests/unit/** - Unit test filesNEVER write to:
src/** - Source code (read-only)tests/integration/** - Out of scopeBefore analyzing the source class, check if the project's phpunit.xml.dist (or phpunit.xml) excludes it from coverage. Files excluded from coverage do not need unit tests.
phpunit.xml.dist from the project root<exclude> rules inside the <coverage> or <source> section<directory suffix="X">path</directory> — excluded if file is under path AND filename ends with X<file>path/to/File.php</file> — excluded if relative path matches exactlyskip_type: coverage_excluded and reason: "Source file excluded from coverage by phpunit.xml.dist (<matched-rule>)"If phpunit.xml.dist is not found, skip this step.
Before generating any test, evaluate if the class/method requires one.
Quick check: Does the method body contain ONLY return <literal|constant|property|passthrough-new|delegation>?
skip_type: no_logic and reason describing the pattern (e.g., "Pure accessor - no logic to test")For detailed rules on what to test vs skip, see references/test-requirement-rules.md.
Read the target class to determine:
@deprecated tags, Feature::triggerDeprecationOrThrow(), Feature::silent(), Feature::callSilentIfInactive() (see references/deprecation-guards.md)#[Package('...')] value the covered class carries. The test class carries the same value. When the covered class carries none, take the value from the nearest src/ directory the test path mirrors, walking up until one exists and using the value its .php files carry. When that yields no value, emit no #[Package] and report that in the Phase 5 report's Package field (none, per references/output-format.md) rather than guessing a value.Use the decision tree to select the appropriate category:
Has constructor dependencies?
├── No → Is it an Exception class?
│ ├── Yes → Category E
│ └── No → Category A (DTO)
└── Yes → Uses EntityRepository?
├── Yes → Category D (DAL)
└── No → Implements EventSubscriberInterface or FlowAction?
├── Yes → Category C (Flow/Event)
└── No → Category B (Service)
For detailed category criteria, see references/category-detection.md.
Apply these mandatory conventions when generating tests.
| Rule | Requirement |
|---|---|
| File location | tests/unit/ mirroring src/ path |
| Class attributes | #[Package('...')] then #[CoversClass(TargetClass::class)], both required |
| Assertions | Use static:: not $this-> |
| Base class | Extend PHPUnit\Framework\TestCase |
| Method naming | test + Action + Condition + ExpectedResult |
| Attribute order | PHPDoc -> DataProvider -> TestDox -> method |
| One behavior | NO conditionals in tests |
TestDox MUST be a predicate phrase starting with an action verb:
StaticEntityRepository, StaticSystemConfigService, GeneratorFor createStub vs createMock selection, see references/mocking-patterns.md.
For complete rules, see references/essential-rules.md.
Based on category from Phase 1:
| Category | Template |
|---|---|
| A (DTO) | templates/category-a-dto.md |
| B (Service) | templates/category-b-service.md |
| C (Flow/Event) | templates/category-c-flow.md |
| D (DAL) | templates/category-d-dal.md |
| E (Exception) | templates/category-e-exception.md |
For data provider and decoration contract patterns, see references/common-patterns.md.
{package} - #[Package] value from Phase 1 Step 3 (e.g., framework, discovery){Module} - Core module (e.g., Content, Checkout, System){Submodule} - Submodule path (e.g., Product, Cart\LineItem){TargetClass} - Class name being tested{Entity} - Entity name for DAL tests{Method} - Method name being tested{Expected} - Expected outcome description{Condition} - Condition description{Exception} - Exception class nameWrite to correct location: tests/unit/{path matching src}/{ClassName}Test.php
- [ ] PHPStan passes (0 errors)
- [ ] PHPUnit passes (all tests green)
- [ ] ECS passes (code style)
{
"paths": ["tests/unit/Path/To/GeneratedTest.php"],
"error_format": "json"
}
Zero errors = pass.
Apply fixes for common errors. See references/validation-error-mapping.md.
{
"paths": ["tests/unit/Path/To/GeneratedTest.php"],
"output_format": "result-only"
}
All tests passing = success. If tests fail, re-run without output_format to get failure details for Step 4.
Apply fixes for common failures. See references/validation-error-mapping.md.
Check for violations, then apply fixes if needed.
Loop through Steps 1-5 until all validations pass.
Maximum iterations: Stop after 3 failed attempts and proceed to Phase 5.
For output format and examples, see references/output-format.md.
| Condition | Status | skip_type |
|---|---|---|
| All validations pass | SUCCESS | — |
| Test generated, validation issues remain after 3 iterations | PARTIAL | — |
| File excluded from coverage in phpunit.xml.dist | SKIPPED | coverage_excluded |
| No testable logic (per Test Requirement Rules) | SKIPPED | no_logic |
| Invalid input (not a PHP class, file not found) | FAILED | — |
none when derivation yielded no value)For detailed patterns and techniques, consult:
Category-specific test generation templates in templates/:
references/category-detection.md (opens in a new tab)references/common-patterns.md (opens in a new tab)references/deprecation-guards.md (opens in a new tab)references/essential-rules.md (opens in a new tab)references/exception-patterns.md (opens in a new tab)references/mocking-patterns.md (opens in a new tab)references/output-format.md (opens in a new tab)references/shopware-stubs.md (opens in a new tab)references/test-requirement-rules.md (opens in a new tab)references/validation-error-mapping.md (opens in a new tab)templates/category-a-dto.md (opens in a new tab)templates/category-b-service.md (opens in a new tab)templates/category-c-flow.md (opens in a new tab)templates/category-d-dal.md (opens in a new tab)templates/category-e-exception.md (opens in a new tab)What SKILL.md sets; muted values are Claude Code's defaults
test-writing:test-generator), in the background11 skills in this plugin
/phpunit-integration-test-generationUse this skill when the user asks to generate, write, or create integration tests for a Shopware 6 source class whose contract requires wired-up code — phrases like "generate integration tests for X", "write an integration test for this controller", "test this indexer", "create an integration test for the message handler". Detects supported integration patterns (controller/route, scheduled-task, message-handler, indexer, DAL-persistence flow, multi-service coordinator) and applies a template producing an INTEGRATION-001..008-compliant test using IntegrationTestBehaviour against the real DAL, container, and HTTP/messaging. When the source class is unit-shape (no persistence, no kernel state, no wiring under test), returns SKIPPED and points at phpunit-unit-test-writing. Do NOT activate for unit tests or migration tests (use phpunit-migration-test-generation)./phpunit-integration-test-reviewingInternal sub-skill. Do not auto-activate. Use only when explicitly invoked by name by another skill or agent./phpunit-integration-to-unit-migratingUse this skill ONLY when the user explicitly requests an audit, migration, or evaluation of whether a Shopware integration test belongs in the unit suite — trigger phrases like "audit integration tests", "migrate integration tests to unit", "is this an integration test or a unit test", "evaluate integration tests for migration", "should this be a unit test instead". Audits tests under tests/integration/ for misplacement and migrates load-bearing-free tests to tests/unit/ using one of six codified refactoring patterns. NOT invoked automatically by reviewing skills — phpunit-integration-test-reviewing emits a placement smoke-alarm hint pointing here, but the user must invoke this skill explicitly to run the deep audit.npx claudepluginhub shopwarelabs/ai-coding-tools --plugin test-writingOther plugins' skills for the same job