Logo de Phpunit Migration Test Generation

Phpunit Migration Test Generation

Organização
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).

Visão geral

Publicado porshopwareLabs
Repositórioai-coding-tools
Nome da habilidadephpunit-migration-test-generation
Estrelas
45
Forks
7
Arquivos incluídos
3
LicençaMIT
Links
  • Instruções em Markdown

    Um arquivo SKILL.md que o modelo carrega sob demanda, consumindo tokens apenas quando uma solicitação é realmente relevante para a habilidade.

  • Funciona com qualquer LLM

    Habilidades de IA são Markdown simples, não código específico de um provedor, por isso funcionam com GPT, Claude, Gemini, Grok ou um modelo local.

  • 3 arquivos incluídos

    Scripts, modelos de documentos e referências que o modelo pode ler enquanto trabalha. Os arquivos são somente leitura e nunca são executados.

  • Código aberto

    Publicada por shopwareLabs no GitHub. Leia o conteúdo-fonte antes de instalar.

Instalação

Instale a habilidade de IA Phpunit Migration Test Generation no TypingMind para usá-la com qualquer LLM ou adicione-a a outro agente que leia SKILL.md.

1

Instalar no TypingMind

O TypingMind instala uma habilidade diretamente da pasta dela no GitHub — lê o arquivo SKILL.md, reúne os arquivos de recursos em um pacote e armazena o resultado localmente.

  1. Abra o app e vá para Plugins → Habilidades.
  2. Escolha "Instalar do GitHub".
  3. Cole a URL da pasta da habilidade exibida abaixo e confirme.
    https://github.com/shopwareLabs/ai-coding-tools/tree/main/plugins/test-writing/skills/phpunit-migration-test-generation
  4. Ative a habilidade em cada chat em que quiser disponibilizá-la.
Plugins → Habilidades → Nova habilidade → Via URL GitHub, depois cole a URL da pasta e pressione Continuar.
2

Instalar em outro agente

Qualquer agente que leia o formato Agent Skills pode usar esta habilidade — copie a pasta para o diretório de habilidades desse agente.

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
Reinicie Claude Code após copiar para que a nova habilidade seja reconhecida.

Use no TypingMind

Ative Phpunit Migration Test Generation em qualquer chat do TypingMind e o modelo cuida do resto. O nome e a descrição da habilidade ficam no prompt do sistema e, assim que uma solicitação relevante aparece, o modelo carrega as instruções completas automaticamente — sem precisar de acionamento manual e sem consumir tokens até que ela seja realmente usada.

O modelo carrega Phpunit Migration Test Generation automaticamente assim que uma solicitação é relevante para essa habilidade.

Funciona com qualquer modelo de IA

Habilidades de IA são instruções em Markdown simples, não código específico de um provedor. Por isso, Phpunit Migration Test Generation não fica vinculada ao modelo para o qual foi criada. Instale-a uma vez no TypingMind e use-a com GPT-5, Claude, Gemini, Grok, DeepSeek, Mistral, Llama ou um modelo local executado por conta própria — tudo com suas próprias chaves de API.

  • Carregada apenas quando necessário

    O prompt do sistema contém apenas o nome e a descrição. As instruções são buscadas na primeira solicitação relevante, então uma habilidade sem uso não gera custo.

  • Troque de modelo durante a conversa

    Como a habilidade é composta de instruções, não de código, trocar de modelo não afeta seu funcionamento — o próximo modelo lê o mesmo arquivo SKILL.md.

Instruções da habilidade

Este é o conteúdo de SKILL.md que o modelo carrega. Leia antes de instalar — uma habilidade é um conjunto de instruções que seu modelo seguirá.

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

Arquivos incluídos

O modelo lê esses arquivos sob demanda enquanto a habilidade está carregada. Eles são disponibilizados para leitura e nunca são executados.

Perguntas frequentes

O que a habilidade de IA Phpunit Migration Test Generation faz?

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

Por que usar Phpunit Migration Test Generation no TypingMind?

Porque basta instalar uma vez para usar com qualquer modelo. Phpunit Migration Test Generation é escrito em Markdown simples, e não em código específico de um provedor, então a mesma habilidade funciona com GPT-5, Claude, Gemini, Grok ou um modelo local — e é possível trocar de modelo no meio do chat sem que ela deixe de funcionar. O TypingMind usa suas próprias chaves de API, então o pagamento é feito diretamente aos provedores, em vez de uma assinatura por licença de usuário, e suas habilidades e chats permanecem no seu próprio armazenamento.

Como instalar Phpunit Migration Test Generation no TypingMind?

Abra Plugins → Habilidades → Instalar do GitHub no TypingMind e cole https://github.com/shopwareLabs/ai-coding-tools/tree/main/plugins/test-writing/skills/phpunit-migration-test-generation. O TypingMind lê o arquivo SKILL.md, reúne os arquivos da habilidade e a instala para que possa ser ativada em cada chat.

Quais modelos de IA podem usar Phpunit Migration Test Generation?

Qualquer modelo conectado no TypingMind. As habilidades de IA são instruções em Markdown simples, e não código específico de um provedor. Assim, GPT, Claude, Gemini, Grok e modelos locais podem carregar esta habilidade quando uma solicitação corresponder a ela.

Quantos modelos de IA posso usar com Phpunit Migration Test Generation?

Quantos quiser. Desde que o modelo ofereça suporte a habilidades, é possível usar Phpunit Migration Test Generation com ele — GPT, Claude, Gemini, Grok, DeepSeek, Mistral, Llama e outros — tudo no TypingMind com suas próprias chaves de API.

A habilidade de IA Phpunit Migration Test Generation é gratuita?

Sim. A habilidade é publicada no GitHub por shopwareLabs sob a licença MIT. O pagamento é feito apenas ao seu provedor de IA pelos tokens usados.

O que são habilidades de IA?

Uma habilidade de IA é um conjunto reutilizável de instruções que ensina um modelo de IA a realizar uma tarefa específica. Ela segue o formato aberto Agent Skills: um arquivo SKILL.md com nome e descrição, além de scripts, modelos de documento ou arquivos de referência de que o modelo possa precisar. O modelo lê as instruções apenas quando sua solicitação corresponde à habilidade, então uma habilidade instalada não gera custos até ser usada.

Qual é a diferença entre habilidades de IA e plugins ou servidores MCP?

Um plugin ou servidor MCP oferece ao modelo novas ferramentas para chamar — código que é executado em algum lugar e retorna um resultado. Já uma habilidade de IA fornece conhecimento e um processo ao modelo: como abordar uma tarefa, quais etapas seguir e como deve ser um bom resultado. As habilidades são escritas em Markdown simples, por isso não precisam de servidor, chave de API nem ambiente de execução, e funcionam com qualquer modelo.

Ver todos

Crie seu próprio espaço de IA agora

Inscreva-se na nossa newsletter para receber novidades sobre recursos e futuros sorteios 👇