Логотип Phpunit Migration Test Generation

Phpunit Migration Test Generation

Організація
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).

Огляд

ВидавецьshopwareLabs
Репозиторійai-coding-tools
Назва навичкиphpunit-migration-test-generation
Зірки
45
Форки
7
Файли в пакеті
3
ЛіцензіяMIT
Посилання
  • Інструкції у форматі Markdown

    Файл SKILL.md, який модель завантажує за потреби, тож токени витрачаються лише тоді, коли запит справді відповідає навичці.

  • Працює з будь-якою LLM

    Навички ШІ — це звичайний Markdown, а не код для певного постачальника, тому вони працюють із GPT, Claude, Gemini, Grok або локальною моделлю.

  • Файлів у комплекті: 3

    Скрипти, шаблони й довідкові матеріали, які модель може читати під час роботи. Файли доступні лише для читання й ніколи не виконуються.

  • Відкритий вихідний код

    Опубліковано на GitHub користувачем shopwareLabs. Перегляньте вихідний вміст перед установленням.

Встановлення

Установіть навичку ШІ Phpunit Migration Test Generation у TypingMind, щоб використовувати її з будь-якою LLM, або додайте її до іншого агента, що читає SKILL.md.

1

Встановити в TypingMind

TypingMind встановлює навичку безпосередньо з її папки GitHub — читає SKILL.md, збирає файли ресурсів у пакет і зберігає результат локально.

  1. Відкрийте застосунок і перейдіть до Плагіни → Навички.
  2. Виберіть «Встановити з GitHub».
  3. Вставте наведений нижче URL папки навички та підтвердьте встановлення.
    https://github.com/shopwareLabs/ai-coding-tools/tree/main/plugins/test-writing/skills/phpunit-migration-test-generation
  4. Увімкніть навичку в кожному чаті, де хочете її використовувати.
Плагіни → Навички → Нова навичка → За URL GitHub, потім вставте URL папки й натисніть «Продовжити».
2

Встановити в іншому агенті

Будь-який агент, що підтримує формат Agent Skills, може використовувати цю навичку — скопіюйте папку до каталогу навичок цього агента.

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
Після копіювання перезапустіть Claude Code, щоб завантажити нову навичку.

Використовуйте навичку в TypingMind

Увімкніть навичку Phpunit Migration Test Generation в будь-якому чаті TypingMind, і далі модель усе зробить сама. Назва й опис навички містяться в системному промпті, а щойно надходить відповідний запит, модель самостійно завантажує повні інструкції — вам не потрібно викликати навичку вручну, і до фактичного використання вона не витрачає токенів.

Модель самостійно завантажує навичку Phpunit Migration Test Generation, щойно надходить відповідний запит.

Працює з будь-якою моделлю ШІ

Навички ШІ — це звичайні інструкції Markdown, а не код для певного постачальника, тому навичка Phpunit Migration Test Generation не прив’язана до моделі, для якої її створено. Установіть її один раз у TypingMind і використовуйте з GPT-5, Claude, Gemini, Grok, DeepSeek, Mistral, Llama або локальною моделлю, яку ви запускаєте самостійно, — усе з вашими власними ключами API.

  • Завантажується лише за потреби

    Системний промпт містить лише назву й опис. Інструкції завантажуються за першого відповідного запиту, тож невикористана навичка нічого не коштує.

  • Змінюйте моделі під час чату

    Оскільки навичка — це інструкції, а не код, зміна моделі не порушує її роботу: наступна модель читає той самий файл SKILL.md.

Інструкції навички

Це вміст файлу SKILL.md, який завантажує модель. Прочитайте його перед установленням — навичка містить інструкції, яких дотримуватиметься ваша модель.

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

Файли в пакеті

Модель читає ці файли за потреби, поки навичку завантажено. Вони доступні для читання й ніколи не виконуються.

Поширені запитання

Що робить навичка ШІ 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...

Навіщо використовувати Phpunit Migration Test Generation у TypingMind?

Тому що ви встановлюєте її один раз і використовуєте з будь-якою моделлю. Phpunit Migration Test Generation — це звичайний Markdown, а не код для конкретного постачальника, тому та сама навичка працює з GPT-5, Claude, Gemini, Grok або локальною моделлю. Ви можете змінити модель навіть посеред чату, і навичка продовжить працювати. TypingMind використовує ваші власні ключі API, тож ви платите безпосередньо постачальникам замість передплати за кожне місце користувача, а ваші навички й чати залишаються у вашому сховищі.

Як встановити Phpunit Migration Test Generation у TypingMind?

Відкрийте в TypingMind Плагіни → Навички → Встановити з GitHub і вставте https://github.com/shopwareLabs/ai-coding-tools/tree/main/plugins/test-writing/skills/phpunit-migration-test-generation. TypingMind прочитає файл SKILL.md, додасть супровідні файли та встановить навичку, яку можна вмикати окремо для кожного чату.

Які моделі ШІ можуть використовувати Phpunit Migration Test Generation?

Будь-яка модель, яку ви підключите в TypingMind. Навички ШІ — це звичайні інструкції у форматі Markdown, а не код для конкретного постачальника, тому GPT, Claude, Gemini, Grok і локальні моделі можуть завантажувати цю навичку, коли запит їй відповідає.

Зі скількома моделями ШІ можна використовувати Phpunit Migration Test Generation?

Зі скількома забажаєте. Якщо модель підтримує навички, ви можете використовувати з нею Phpunit Migration Test Generation — GPT, Claude, Gemini, Grok, DeepSeek, Mistral, Llama та інші — усе в TypingMind із власними ключами API.

Чи безкоштовна навичка ШІ Phpunit Migration Test Generation?

Так. Навичку опубліковано на GitHub: shopwareLabs, за ліцензією MIT. Ви платите лише своєму постачальнику ШІ за використані токени.

Що таке навички ШІ?

Навичка ШІ — це багаторазовий набір інструкцій, який навчає модель ШІ виконувати одне конкретне завдання. Він відповідає відкритому формату Agent Skills: файл SKILL.md із назвою та описом, а також скрипти, шаблони чи довідкові файли, які можуть знадобитися моделі. Модель читає інструкції лише тоді, коли ваш запит відповідає навичці, тому встановлена навичка нічого не коштує, доки її не використано.

Чим навички ШІ відрізняються від плагінів або серверів MCP?

Плагін або сервер MCP надає моделі нові інструменти для виклику — код, який десь виконується й повертає результат. Натомість навичка ШІ надає моделі знання та порядок дій: як підійти до завдання, яких кроків дотримуватися та яким має бути якісний результат. Навички — це звичайний Markdown, тож їм не потрібні ні сервер, ні ключ API, ні середовище виконання, і вони працюють із будь-якою моделлю.

Усі

Створіть власний ШІ-простір уже зараз

Підпишіться на нашу розсилку, щоб дізнаватися про нові функції та майбутні розіграші 👇