Magento 2 Test Essentials

View on GitHub

Clean fake objects and lightweight test doubles for Magento 2 that replace brittle mocks and slow full-app integration bootstraps.

Overview

Magento 2's stock integration test framework boots the entire application, runs DI compilation, and executes slow setup scripts before running a single assertion. Conversely, pure mock-based unit tests quickly become brittle mirrors of internal method calls.

EcomDev/magento2-test-essentials provides clean, composable fake implementations of core Magento infrastructure services, giving you real behavior and real database queries without booting the whole framework.

Installation

composer require --dev ecomdev/magento2-test-essentials

Key Building Blocks

  • ObjectManager Fake: Register only the collaborators your subject under test actually needs.
  • StoreManager & ScopeConfig Fakes: Configure multi-website, multi-store hierarchies and scoped config values in a few lines of PHP.
  • DeploymentConfig & ResourceConnection Fakes: Wire Magento resource models directly to a live testcontainer-magento-data-php database container.

More in Automation Tools

View all Automation Tools →