Phpunit Migration Test Generation logo

Phpunit Migration Test Generation

Organization
shopwareLabs
phpunit-migration-test-generation

Use 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).

Overview

PublishershopwareLabs
Repositoryai-coding-tools
Skill namephpunit-migration-test-generation
Stars
45
Forks
7
Bundled files
3
LicenseMIT
Links
  • Markdown instructions

    A SKILL.md file the model loads on demand, so it only costs tokens when a request actually matches.

  • Works with any LLM

    AI skills are plain Markdown, not provider-specific code, so this works with GPT, Claude, Gemini, Grok, or a local model.

  • 3 bundled files

    Scripts, templates, and references the model can read while it works. Files are read-only and never executed.

  • Open source

    Published by shopwareLabs on GitHub. Read the source before you install it.

Installation

Install the Phpunit Migration Test Generation AI skill in TypingMind to use it with any LLM, or drop it into another agent that reads SKILL.md.

1

Install in TypingMind

TypingMind installs a skill straight from its GitHub folder — it reads SKILL.md, bundles the resource files, and stores the result locally.

  1. Open the app and go to Plugins → Skills.
  2. Choose "Install from GitHub".
  3. Paste the skill folder URL below and confirm.
    https://github.com/shopwareLabs/ai-coding-tools/tree/main/plugins/test-writing/skills/phpunit-migration-test-generation
  4. Enable the skill in any chat where you want it available.
Plugins → Skills → Add skill → From GitHub URL, then paste the folder URL and press Continue.
2

Install in another agent

Any agent that reads the Agent Skills format can use this skill — copy the folder into that agent's skills directory.

Claude Code — .claude/skills
git clone --depth 1 https://github.com/shopwareLabs/ai-coding-tools.git /tmp/ai-coding-tools
mkdir -p .claude/skills
cp -r /tmp/ai-coding-tools/plugins/test-writing/skills/phpunit-migration-test-generation .claude/skills/phpunit-migration-test-generation
Restart Claude Code after copying so it picks up the new skill.

Use it in TypingMind

Enable Phpunit Migration Test Generation in any TypingMind chat and the model takes it from there. Its name and description sit in the system prompt, and the moment a request matches, the model loads the full instructions itself — you never invoke it by hand, and it costs no tokens until it is actually used.

The model loads Phpunit Migration Test Generation on its own as soon as a request matches it.

Works with any AI model

AI skills are plain Markdown instructions rather than provider-specific code, so Phpunit Migration Test Generation is not tied to the model it was written for. Install it once in TypingMind and use it with GPT-5, Claude, Gemini, Grok, DeepSeek, Mistral, Llama, or a local model you run yourself — all on your own API keys.

  • Loaded only when it is needed

    The system prompt carries just the name and description. The instructions are fetched on the first matching request, so an idle skill costs nothing.

  • Switch models mid-chat

    Because the skill is instructions rather than code, changing model does not break it — the next model reads the same SKILL.md.

Skill instructions

This is the SKILL.md content the model loads. Read it before installing — a skill is instructions your model will follow.

PHPUnit Migration Test Generation

Generate Shopware-compliant PHPUnit migration tests that pass PHPStan and PHPUnit validation.

File Write Restrictions

Write ONLY to:

  • tests/migration/** — Migration test files

NEVER write to:

  • src/** — Source code (read-only)
  • tests/unit/** — Unit tests (out of scope)
  • tests/integration/** — Integration tests (out of scope)
  • Any other directory

Quick Start

  1. Read the target migration source class
  2. Analyze SQL operations to determine test pattern
  3. Apply the migration test template with conditional sections
  4. Validate with PHPStan and PHPUnit
  5. Fix any errors and repeat
  6. Generate completion report

Phase 1: Validate Input

  1. Verify single file provided
  2. Verify file exists and is a PHP class (not interface/trait)
  3. Verify path contains Migration/V6_
  4. Verify class extends Shopware\Core\Framework\Migration\MigrationStep

If validation fails, return FAILED with reason.

Phase 2: Analyze Source

Read the migration class and extract information needed for test generation. See references/source-analysis.md for detection patterns.

Step 1: Extract Metadata

  • Class name, full namespace
  • Timestamp from getCreationTimestamp() return value
  • #[Package('...')] attribute value — the test class carries the same value. When the migration 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.
  • Area from namespace (Core, Administration, Storefront, Elasticsearch)
  • Version from namespace (V6_6, V6_7, V6_8)

Step 2: Classify SQL Operations

Read update() and updateDestructive() method bodies. Classify:

  • Schema-add: CREATE TABLE, addColumn(), ALTER TABLE ... ADD
  • Schema-remove: DROP TABLE, DROP COLUMN, dropColumnIfExists(), dropTableIfExists()
  • Data-update: UPDATE, INSERT, DELETE on non-config tables
  • Config: system_config operations
  • Mail-template: mail_template operations

A migration may contain multiple patterns (e.g., schema-add + data-update).

Step 3: Check updateDestructive

Determine if updateDestructive() has logic:

  • Not overridden → no logic
  • Empty body or only parent::updateDestructive() → no logic
  • Any other statement → has logic

Step 4: Select Traits

Based on detected patterns, select traits per references/source-analysis.md trait selection table.

Phase 3: Generate Test

Step 1: Determine Test Path

Mirror source path:

  • src/Core/Migration/V6_7/Migration1234Foo.php → tests/migration/Core/V6_7/Migration1234FooTest.php
  • src/Administration/Migration/V6_7/Migration1234Bar.php → tests/migration/Administration/V6_7/Migration1234BarTest.php

Step 2: Apply Template

Use the migration test template at templates/migration-test.md. Include conditional sections based on Phase 2 analysis:

  • Always: base template, testGetCreationTimestamp, setUp with Connection
  • Schema-add detected: rollback method, schema verification test
  • updateDestructive has logic: updateDestructive test method
  • Data-update detected: state setup, value assertion test
  • Config detected: config insert/preserve tests
  • Mail-template detected: minimal no-exception test

Fill all placeholders using Phase 2 metadata.

Step 3: Write Test File

Write to the path determined in Step 1.

Phase 4: Validate and Fix

Validation Loop

- [ ] PHPStan passes (0 errors)
- [ ] PHPUnit passes (all tests green)
- [ ] ECS passes (code style)

Step 1: Run PHPStan

json
{
  "paths": ["tests/migration/Path/To/GeneratedTest.php"],
  "error_format": "json"
}

Step 2: Fix PHPStan Errors

Common migration test errors:

  • Missing imports for TableHelper, KernelLifecycleManager, Uuid, Defaults
  • Type mismatches in assertion arguments
  • Unknown method calls on Connection

Step 3: Run PHPUnit

json
{
  "paths": ["tests/migration/Path/To/GeneratedTest.php"],
  "output_format": "result-only"
}

If tests fail, re-run without output_format to get failure details.

Step 4: Fix Test Failures

Common migration test failures:

  • Column/table already exists (rollback not working)
  • Wrong timestamp value
  • Missing test data setup
  • Transaction not rolling back (wrong trait)

Step 5: Run ECS Check and Fix

Check for violations, then apply fixes if needed.

Repeat Until Pass

Loop Steps 1-5 until all validations pass. Maximum 3 iterations — after that, proceed to Phase 5 with status PARTIAL.

Phase 5: Generate Report

For output format and examples, see references/output-format.md.

Status Determination

ConditionStatus
All validations passSUCCESS
Test generated, validation issues remain after 3 iterationsPARTIAL
Invalid inputFAILED

Bundled files

The model reads these on demand while the skill is loaded. They are exposed as readable files and are never executed.

Frequently asked questions

What does the Phpunit Migration Test Generation AI skill do?

Use 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...

Why use Phpunit Migration Test Generation on TypingMind?

Because you install it once and use it with any model. Phpunit Migration Test Generation is plain Markdown rather than provider-specific code, so the same skill runs on GPT-5, Claude, Gemini, Grok, or a local model — and you can switch model mid-chat without it breaking. TypingMind runs on your own API keys, so you pay providers directly instead of a per-seat subscription, and your skills and chats stay in your own storage.

How do I install Phpunit Migration Test Generation in TypingMind?

Open Plugins → Skills → Install from GitHub in TypingMind and paste https://github.com/shopwareLabs/ai-coding-tools/tree/main/plugins/test-writing/skills/phpunit-migration-test-generation. TypingMind reads its SKILL.md and bundles its files and installs it as a skill you can enable per chat.

Which AI models can use Phpunit Migration Test Generation?

Any model you connect in TypingMind. AI skills are plain Markdown instructions rather than provider-specific code, so GPT, Claude, Gemini, Grok, and local models can all load this skill when a request matches it.

How many AI models can I use with Phpunit Migration Test Generation?

As many as you like. As long as a model supports skills, you can use Phpunit Migration Test Generation with it — GPT, Claude, Gemini, Grok, DeepSeek, Mistral, Llama and more — all on TypingMind with your own API keys.

Is the Phpunit Migration Test Generation AI skill free?

Yes. It is published on GitHub by shopwareLabs under the MIT license. You only pay your own AI provider for the tokens you use.

What are AI skills?

An AI skill is a reusable instruction bundle that teaches an AI model how to do one specific task. It follows the open Agent Skills format: a SKILL.md file with a name and description, plus any scripts, templates or reference files the model may need. The model reads the instructions only when your request matches the skill, so an installed skill costs nothing until it is used.

How are AI skills different from plugins or MCP servers?

A plugin or MCP server gives a model new tools to call — code that runs somewhere and returns a result. An AI skill gives the model knowledge and process instead: how to approach a task, which steps to follow, what good output looks like. Skills are plain Markdown, so they need no server, no API key and no runtime, and they work with any model.

View all

Set up your own AI workspace now

Get notified about new features and future giveaways by subscribing to our newsletter 👇