# Shopware Phpunit

> Best practices for writing PHPUnit tests in Shopware 6 projects, including integration tests, unit tests, and common testing patterns for plugins and apps.

- Skill: `friendsofshopware/shopware-phpunit` (Agent Skill, multi-file: 14 files)
- Install (CLI): `npx skillmds@latest add friendsofshopware/shopware-phpunit`
- Raw SKILL.md: https://api.skillmd.com/api/skills/friendsofshopware/shopware-phpunit/raw
- Safety review: pending
- Works with: Claude Code, Claude.ai, OpenAI Codex
- Category: Integrations & APIs
- License: MIT
- Author: friendsofshopware (https://skillmd.com/u/friendsofshopware)
- Updated: 2026-09-17
- Page: https://skillmd.com/skills/friendsofshopware/shopware-phpunit

---


# Shopware PHPUnit Best Practices

## When to Apply

- Writing new PHPUnit tests for a Shopware 6 plugin or app
- Setting up test infrastructure for a Shopware project
- Testing repositories, services, commands, or event subscribers
- Writing integration tests that require the Shopware kernel
- Testing Storefront controllers or Store API / Admin API routes
- Debugging failing tests in a Shopware context

## Rule Categories by Priority

| Priority | Category | Prefix | Description |
|----------|----------|--------|-------------|
| CRITICAL | Test Setup | `setup-` | Kernel bootstrap, base test classes, PHPUnit configuration |
| HIGH | Integration Testing | `integration-` | Repository tests, service tests, database transactions |
| HIGH | API Testing | `api-` | Store API and Admin API endpoint testing |
| MEDIUM | Mocking | `mock-` | Service mocking, dependency injection in tests |
| MEDIUM | Data | `data-` | Test data creation, fixtures, cleanup |
| LOW | Performance | `perf-` | Test execution speed, parallel testing |

## How to Use

Read relevant reference files from the `references/` directory based on the task at hand. Files are prefixed by category for easy discovery.

## External References

- [Shopware Developer Documentation - Testing](https://developer.shopware.com/docs/guides/plugins/plugins/testing)
- [PHPUnit Documentation](https://docs.phpunit.de/)

