/test-writing:phpunit-integration-to-unit-migratingfrom test-writing
Audits Shopware integration tests for misplacement and migrates eligible tests to the unit suite using six codified refactoring patterns. Invoke explicitly for migration audits.
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.
Audits integration tests for misplacement and migrates the ones whose apparatus is not load-bearing.
phpunit-integration-test-reviewingThis skill is adversarial about placement. It assumes integration tests are misplaced until proven otherwise. Do not invoke for general integration test review — use phpunit-integration-test-reviewing for that.
digraph migration_audit {
"User invocation" [shape=doublecircle];
"Resolve scope" [shape=box];
"Per test: articulate SUT contract" [shape=box];
"Walk PLACEMENT-001..008" [shape=box];
"Veto from PLACEMENT-008?" [shape=diamond];
"Bucket: migrate" [shape=box];
"Bucket: split" [shape=box];
"Bucket: keep" [shape=box];
"Bucket: delete (duplicate)" [shape=box];
"Present buckets to user" [shape=box];
"User confirms migration set?" [shape=diamond];
"Execute migrations" [shape=box];
"Report" [shape=doublecircle];
"Stop (user declined)" [shape=octagon, style=filled, fillcolor=red];
"User invocation" -> "Resolve scope";
"Resolve scope" -> "Per test: articulate SUT contract";
"Per test: articulate SUT contract" -> "Walk PLACEMENT-001..008";
"Walk PLACEMENT-001..008" -> "Veto from PLACEMENT-008?";
"Veto from PLACEMENT-008?" -> "Bucket: keep" [label="yes (any veto)"];
"Veto from PLACEMENT-008?" -> "Bucket: migrate" [label="no, all unit-shape"];
"Veto from PLACEMENT-008?" -> "Bucket: split" [label="no, mixed"];
"Veto from PLACEMENT-008?" -> "Bucket: delete (duplicate)" [label="duplicate of unit coverage"];
"Bucket: migrate" -> "Present buckets to user";
"Bucket: split" -> "Present buckets to user";
"Bucket: keep" -> "Present buckets to user";
"Bucket: delete (duplicate)" -> "Present buckets to user";
"Present buckets to user" -> "User confirms migration set?";
"User confirms migration set?" -> "Execute migrations" [label="yes"];
"User confirms migration set?" -> "Stop (user declined)" [label="no"];
"Execute migrations" -> "Report";
}
tests/integration/Core/.../SomeTest.phptests/integration/Core/Framework/App/Cms/#[CoversClass] and constructor of the SUT class(es) to ground later deliberation.For each test class in scope, before running any rule:
OrderIndexerTest → "The SUT rebuilds order line-item state from persisted product and discount data."DateFieldSerializerTest → "The SUT serializes and deserializes date values via the field serializer's encode/decode methods."This step is not optional. Without an articulated contract, the rules below collapse into pattern matching on imports and produce false positives. Record the sentence in the bucket report.
mcp__plugin_test-writing_test-rules__get_rules(group=placement) to load PLACEMENT-001..008mcp__plugin_test-writing_test-rules__get_rules(group=integration, test_type=integration) to have quality rules available — INTEGRATION-002 mock detection informs PLACEMENT-005's collaborator-graph reasoning, and INTEGRATION-008's assertion-shape catalog is referenced by PLACEMENT-004.For each test method in each file:
tests/unit/) → bucket: delete (duplicate) — remove without re-creating; cross-reference existing unit testPresent the buckets to the user via the report format in references/output-format.md. Then call AskUserQuestion to confirm which buckets to execute:
migrate set (default: all)split set (default: all)delete set (default: all)keep set requires no actionDo NOT execute migrations without explicit user confirmation. If the user declines or wants to narrow, stop and report the audit only.
For each test or method in the confirmed set, apply the appropriate refactoring pattern from references/refactoring-patterns.md:
ContainerBuilder, register definitions, call $pass->process($container), assert on definitionstests/unit/.../_fixtures/Resources/, drop kernel project dirValidator via Validation::createValidatorBuilder(), build the rule object, assert on ConstraintViolationListFor each migration:
tests/unit/... mirroring the source class's namespace#[Package('...')] carrying the unit-shape SUT's own value, then #[CoversClass(...)] matching that SUT (import Shopware\Core\Framework\Log\Package). Where the SUT carries no #[Package], take the value from the nearest src/ directory the test path mirrors; where that yields no value, add no #[Package] and record that against the created file in the Phase 7 report's Files Created list (none, per references/output-format.md) rather than guessing a valueFor delete (duplicate) items: simply delete the integration test method/file and cross-reference the existing unit test in the report.
Produce the final report per references/output-format.md: bucket summary, files created, files modified, files deleted, methods moved. Do NOT commit — leave the working tree dirty for the user to review.
scope:
type: file | directory | pr | branch
resolved_files: [tests/integration/...]
audit:
- file: tests/integration/Path/To/SomeTest.php
sut_contract: "The SUT..."
contract_shape: unit | integration | mixed
placement_verdicts:
PLACEMENT-001: service_locator | sut | n/a
PLACEMENT-002: materializer | dal_behavior | n/a
PLACEMENT-003: kernel_under_test | container_only | n/a
PLACEMENT-004: all_unit | mixed | majority_integration
PLACEMENT-005: r_count_0 | r_count_1 | r_count_2_plus
PLACEMENT-006: minimum_smaller | minimum_equal
PLACEMENT-007: name_body_coherent | name_misleading
PLACEMENT-008: veto_persistence | veto_wiring | veto_http | veto_multi_service | veto_migration | veto_broker | veto_compiler_pass | no_veto
bucket: migrate | split | keep | delete
veto_reason: null # filled when PLACEMENT-008 vetoes
execution:
files_created: [tests/unit/...]
files_modified: [tests/integration/...] # partial migrations
files_deleted: [tests/integration/...] # whole-class migrations or duplicates
methods_moved: 12
status: AUDITED | MIGRATED | DECLINED | FAILED
| Status | Condition |
|---|---|
| AUDITED | Audit complete; user declined to migrate (or no migration candidates found) |
| MIGRATED | User confirmed and migrations executed |
| DECLINED | User declined to proceed after audit |
| FAILED | Invalid scope, source unreachable, or rules not loadable |
If mcp__plugin_test-writing_test-rules__get_rules is unavailable, abort with: "test-rules MCP server not available — ensure the test-writing plugin is installed and Claude Code was restarted." Do not attempt the audit from memory; the rules are the load-bearing reasoning prompts.
If the SUT contract cannot be articulated in one sentence (the test does too many things, the #[CoversClass] is missing, the SUT is unclear), bucket the test as keep with reason "SUT contract unclear — refactor the test for clarity before considering migration." Do not migrate ambiguous tests.
If > 20 integration test files are in scope, ask the user via AskUserQuestion whether to narrow scope or proceed in batches. Batch by directory or #[CoversClass] namespace.
If a test does not fit any of the patterns in references/refactoring-patterns.md but the rules say migrate, bucket as keep with reason "Migration would require a novel refactoring pattern not yet codified — consider keeping in integration and capturing the pattern as a follow-up."
The skill does not run PHPUnit/PHPStan/ECS. After execution, the user (or a follow-up invocation of phpunit-unit-test-writing / phpunit-unit-test-reviewing) validates the migrated tests. Do not claim the migration is correct without that validation step.
What SKILL.md sets; muted values are Claude Code's defaults
11 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-migration-test-generationUse this skill when the user asks to generate, write, or create migration tests for a Shopware 6 migration class — phrases like "generate migration tests", "write a migration test", "create migration test", "test this migration", "test Migration1234Foo". Analyzes the source migration's SQL operations to pick an appropriate pattern (schema-add, schema-remove, data-update, config, mail template), then generates a test that runs against a real database and passes PHPStan and PHPUnit validation. Do NOT activate for unit tests (use phpunit-unit-test-writing) or integration tests of non-migration source classes (use phpunit-integration-test-generation)./phpunit-migration-test-reviewingInternal sub-skill. Do not auto-activate. Use only when explicitly invoked by name by another skill or agent./phpunit-test-adversarial-reviewingInternal sub-skill. Do not auto-activate. Use only when explicitly invoked by name by another skill or agent./phpunit-test-reconcilingInternal sub-skill. Do not auto-activate. Use only when explicitly invoked by name by another skill or agent.npx claudepluginhub shopwarelabs/ai-coding-tools --plugin test-writingOther plugins' skills for the same job