magento-testing

Write tests for Magento 2 — PHPUnit unit tests, integration tests, MFTF functional tests, and API tests. Use when implementing test coverage for modules, debugging, or setting up CI/CD test pipelines.

17 stars

Best use case

magento-testing is best used when you need a repeatable AI agent workflow instead of a one-off prompt.

Write tests for Magento 2 — PHPUnit unit tests, integration tests, MFTF functional tests, and API tests. Use when implementing test coverage for modules, debugging, or setting up CI/CD test pipelines.

Teams using magento-testing should expect a more consistent output, faster repeated execution, less prompt rewriting.

When to use this skill

  • You want a reusable workflow that can be run more than once with consistent structure.

When not to use this skill

  • You only need a quick one-off answer and do not need a reusable workflow.
  • You cannot install or maintain the underlying files, dependencies, or repository context.

Installation

Claude Code / Cursor / Codex

$curl -o ~/.claude/skills/magento-testing/SKILL.md --create-dirs "https://raw.githubusercontent.com/OrcaQubits/agentic-commerce-skills-plugins/main/dist/antigravity/magento2-commerce/.agent/skills/magento-testing/SKILL.md"

Manual Installation

  1. Download SKILL.md from GitHub
  2. Place it in .claude/skills/magento-testing/SKILL.md inside your project
  3. Restart your AI agent — it will auto-discover the skill

How magento-testing Compares

Feature / Agentmagento-testingStandard Approach
Platform SupportNot specifiedLimited / Varies
Context Awareness High Baseline
Installation ComplexityUnknownN/A

Frequently Asked Questions

What does this skill do?

Write tests for Magento 2 — PHPUnit unit tests, integration tests, MFTF functional tests, and API tests. Use when implementing test coverage for modules, debugging, or setting up CI/CD test pipelines.

Where can I find the source code?

You can find the source code on GitHub using the link provided at the top of the page.

Related Guides

SKILL.md Source

# Magento 2 Testing

## Before writing code

**Fetch live docs**:
1. Web-search `site:developer.adobe.com commerce testing` for testing overview
2. Fetch `https://developer.adobe.com/commerce/testing/functional-testing-framework/` for MFTF guide
3. Web-search `site:developer.adobe.com commerce php development test` for unit/integration test patterns

## Testing Layers

### Unit Tests

**Purpose**: Test individual classes in isolation.

- Location: `Test/Unit/` within the module
- Config: `dev/tests/unit/phpunit.xml.dist`
- Run: `vendor/bin/phpunit -c dev/tests/unit/phpunit.xml.dist app/code/VendorName/ModuleName/Test/Unit/`
- Mock all dependencies with PHPUnit mocks or `createMock()`
- No Magento bootstrap — pure PHP unit testing
- Fast execution, no database or filesystem dependencies

### Integration Tests

**Purpose**: Test module interactions with the Magento framework.

- Location: `Test/Integration/` or `dev/tests/integration/`
- Config: `dev/tests/integration/phpunit.xml.dist`
- Run: `vendor/bin/phpunit -c dev/tests/integration/phpunit.xml.dist`
- Uses Magento application bootstrap — real DI, real database
- `@magentoDbIsolation enabled` — rolls back DB changes after each test
- `@magentoAppArea` — sets the application area (frontend, adminhtml)
- `@magentoConfigFixture` — sets config values for the test
- `@magentoDataFixture` — loads test data
- Slower but tests real interactions

### MFTF (Magento Functional Testing Framework)

**Purpose**: End-to-end browser tests.

- XML-based test definitions (not PHP)
- Converts to Codeception PHP tests
- Uses Selenium WebDriver for browser automation
- Allure reporting for results
- Location: `Test/Mftf/Test/`, `Test/Mftf/ActionGroup/`, `Test/Mftf/Page/`, `Test/Mftf/Section/`
- Run: `vendor/bin/mftf run:test <TestName>`
- Tests complete user workflows (add to cart, checkout, admin operations)

### API Functional Tests

**Purpose**: Test REST and SOAP API endpoints.

- Location: `dev/tests/api-functional/`
- Config: `dev/tests/api-functional/phpunit_rest.xml.dist`
- Tests API request/response contracts
- Verifies authentication, authorization, and data integrity

### Static Tests

**Purpose**: Code quality and standards.

- Location: `dev/tests/static/`
- Checks: coding standards (PHP_CodeSniffer + Magento standard), dependency validation, copyright headers
- Run: `vendor/bin/phpunit -c dev/tests/static/phpunit.xml.dist`

## Key Testing Patterns

### Mocking in Magento

- Use `$this->createMock(ClassName::class)` for dependencies
- `$mock->expects($this->once())->method('getById')->willReturn($entity)`
- For ObjectManager-dependent classes: use `ObjectManagerHelper` from test framework

### Test Data Fixtures

Integration tests use fixtures to set up test state:
- `@magentoDataFixture` annotation points to a fixture file
- Fixture files create entities (products, customers, orders)
- `@magentoDbIsolation` rolls back after test

### Testing Plugins

Unit test plugin classes independently — call the plugin method with a mock subject and verify behavior.

### Testing Observers

Unit test observer's `execute()` method with a mocked Observer/Event object.

## Best Practices

- Write unit tests for all business logic classes
- Use integration tests for DI wiring and database interaction verification
- Use MFTF for critical user journeys (checkout, customer registration)
- Run static tests in CI/CD to enforce coding standards
- Use `@magentoDbIsolation` to prevent test pollution
- Keep unit tests fast — mock all external dependencies
- Name test methods descriptively: `testSaveThrowsExceptionWhenNameIsEmpty()`

Fetch the testing documentation for exact annotations, fixture patterns, and MFTF XML schema before writing tests.

Related Skills

woo-testing

17
from OrcaQubits/agentic-commerce-skills-plugins

Test WooCommerce extensions — PHPUnit unit/integration tests, WP test suite, WooCommerce test helpers, E2E with Playwright, and WP-CLI test scaffolding. Use when writing tests for WooCommerce plugins or setting up a test environment.

webmcp-testing

17
from OrcaQubits/agentic-commerce-skills-plugins

Test WebMCP tools with AI agents — Chrome DevTools integration, agent testing workflows, tool discovery verification, and end-to-end commerce flow testing. Use when validating that tools work correctly with real AI agents.

spree-testing

17
from OrcaQubits/agentic-commerce-skills-plugins

Test Spree applications and extensions with RSpec — `spree_dev_tools` gem (v5.2+) for factories and helpers, FactoryBot patterns (prefer `build` over `create`), Capybara feature specs, controller/request specs, testing decorators and subscribers, dummy app for extension testing, system specs for the Hotwire admin, and CI patterns. Use when writing Spree tests, setting up CI, or refactoring slow specs.

shopify-testing

17
from OrcaQubits/agentic-commerce-skills-plugins

Test Shopify applications — app testing with Vitest and Playwright, theme testing with Theme Check, Function testing, webhook testing, extension testing, and CI/CD pipelines. Use when writing tests for Shopify projects.

sf-testing

17
from OrcaQubits/agentic-commerce-skills-plugins

Test Salesforce Commerce code — B2C (Node.js unit testing, sfcc-ci CI/CD, sandbox management, linting) and B2B (Apex test classes with 75% coverage minimum, Jest for LWC, sf CLI deployment and validation). Use when writing tests or setting up CI/CD.

saleor-testing

17
from OrcaQubits/agentic-commerce-skills-plugins

Test Saleor applications — pytest setup, Django test client, GraphQL test patterns, App testing, factory_boy fixtures, and webhook testing. Use when writing tests for Saleor projects.

medusa-testing

17
from OrcaQubits/agentic-commerce-skills-plugins

Test Medusa v2 applications — Jest setup, module unit tests, workflow integration tests, API route tests, medusaIntegrationTestRunner, and mock patterns. Use when writing tests for Medusa projects.

php-testing

17
from OrcaQubits/agentic-commerce-skills-plugins

Write PHP tests with PHPUnit — unit tests, mocking, data providers, test doubles, assertions, and TDD practices. Use when writing tests for PHP code, whether in Magento or standalone PHP applications.

magento-setup

17
from OrcaQubits/agentic-commerce-skills-plugins

Set up a Magento 2 Open Source project — installation, Composer setup, system requirements verification, and initial configuration. Use when starting a new Magento project or setting up a development environment.

magento-service-contracts

17
from OrcaQubits/agentic-commerce-skills-plugins

Implement Magento 2 service contracts — repository interfaces, data interfaces, SearchCriteria, and the repository pattern. Use when building module APIs, data access layers, or integrating with Magento's Web API.

magento-security

17
from OrcaQubits/agentic-commerce-skills-plugins

Implement Magento 2 security — CSP, 2FA, CSRF protection, ACL, admin security configuration, input validation, and security best practices. Use when hardening a Magento installation or reviewing security posture.

magento-plugins-interceptors

17
from OrcaQubits/agentic-commerce-skills-plugins

Implement Magento 2 plugins (interceptors) — before, after, and around methods for modifying class behavior without inheritance. Use when extending core or third-party module functionality.