hardman-commerce / magento2-fixtures
Fixture library for Magento 2 integration tests
Installs: 15
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 0
Forks: 31
Type:magento2-module
Requires
- php: ^8.1
- fakerphp/faker: ^1.9.1
- magento/framework: ^103.0.4
- magento/module-catalog: ^104.0.4
- magento/module-catalog-inventory: ^100.4.4
- magento/module-checkout: ^100.4.4
- magento/module-customer: ^103.0.4
- magento/module-directory: ^100.4.4
- magento/module-indexer: ^100.4.4
- magento/module-payment: ^100.4.4
- magento/module-quote: ^101.2.4
- magento/module-sales: ^103.0.4
- magento/zendframework1: ^1.14
Requires (Dev)
- ext-json: *
- magento/module-store: ^101.0
- pds/skeleton: ^1.0
- phpro/grumphp: ^0.19.0
- phpstan/phpstan: ^0.12.0
- phpunit/phpunit: ^6.0|^9.0
- squizlabs/php_codesniffer: ^3.3.1
This package is auto-updated.
Last update: 2025-09-10 09:38:02 UTC
README
Forked from Magento 2 Fixtures by Fabian Schmengler.
Updated with code from Klevu Test Fixtures.
What is it?
An alternative to the procedural script-based fixtures in Magento 2 integration tests.
It aims to be:
- extensible
- expressive
- easy to use
Installation
Install it into your Magento 2 project with composer:
composer require --dev hardman-commerce/magento2-fixtures
Requirements
- Magento 2.4.4+
- PHP 8.1+
Documentation:
Catalog/Attribute
Fixtures and Traits to build catalog attributes, including store scope settings.
Useful when an attribute is required to create configurable products.
Catalog/Category
Fixtures and Traits to build categories, including store scope settings.
Catalog/Product
Fixtures and Traits to build products, including store scope settings.
Extended TDDWizard product fixtures to add
- Tier Prices
- Images
The following product types are covered
- Simple
- Virtual
- Downloadable
- Grouped
- Configurable
Todo:
- Bundle
- Gift Card
Catalog/Rule
Fixtures and Traits to build catalog price rules.
Checkout
Fixtures and Traits to build Cart and perform a customer checkout.
Add the following product types to the cart:
- Simple
- Configurable
- Grouped
Todo:
- Bundle
- Gift Card
CMS
Fixtures and Traits to build:
- Pages
Todo:
- Blocks
- Widgets
Core
Fixtures to create config settings.
Customer
Fixtures and Traits to build:
- Customer Addresses
- Customers
- Customer Groups
Sales
Fixtures to build:
- Credit memos
- Invoices
- Orders
- Shipments
Todo:
- Create traits
Store
Fixtures and Traits to build:
- Stores
- Store Groups
- Websites
Tax
Fixtures and Traits to build
- Tax Classes
- Tax Rates
- Tax Rules
Fixture pools
To manage multiple fixtures, fixture pools have been introduced for all entities:
Usage demonstrated with the ProductFixturePool
:
protected function setUp()
{
$this->productFixtures = new ProductFixturePool;
}
protected function tearDown()
{
$this->productFixtures->rollback();
}
public function testSomethingWithMultipleProducts()
{
$this->productFixtures->add(ProductBuilder::aSimpleProduct()->build());
$this->productFixtures->add(ProductBuilder::aSimpleProduct()->build(), 'foo');
$this->productFixtures->add(ProductBuilder::aSimpleProduct()->build());
$this->productFixtures->get(); // returns ProductFixture object for last added product
$this->productFixtures->get('foo'); // returns ProductFixture object for product added with specific key 'foo'
$this->productFixtures->get(0); // returns ProductFixture object for first product added without specific key (numeric array index)
}
Credits
License
The MIT License (MIT). Please see License File for more information.