Download the PHP package tddwizard/magento2-fixtures without Composer
On this page you can find all versions of the php package tddwizard/magento2-fixtures. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download tddwizard/magento2-fixtures
More information about tddwizard/magento2-fixtures
Files in tddwizard/magento2-fixtures
Package magento2-fixtures
Short Description Fixture library for Magento 2 integration tests
License MIT
Informations about the package magento2-fixtures
TddWizard Fixture library
Magento 2 Fixtures by Fabian Schmengler
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 tddwizard/magento2-fixtures
Requirements
- Magento 2.3 or Magento 2.4
- PHP 7.3 or 7.4 (7.1 and 7.2 is allowed via composer for full Magento 2.3 compatibility but not tested anymore)
Usage examples:
Customer
If you need a customer without specific data, this is all:
It uses default sample data and a random email address. If you need the ID or email address in the tests, the CustomerFixture
gives you access:
You can configure the builder with attributes:
You can add addresses to the customer:
Or just one:
The CustomerFixture
also has a shortcut to create a customer session:
Addresses
Similar to the customer builder you can also configure the address builder with custom attributes:
Product
Product fixtures work similar as customer fixtures:
The SKU is randomly generated and can be accessed through ProductFixture
, just as the ID:
Cart/Checkout
To create a quote, use the CartBuilder
together with product fixtures:
Checkout is supported for logged in customers. To create an order, you can simulate the checkout as follows, given a customer fixture with default shipping and billing addresses and a product fixture:
It will try to select the default addresses and the first available shipping and payment methods.
You can also select them explicitly:
Order
The OrderBuilder
is a shortcut for checkout simulation.
Logged-in customer, products, and cart item quantities will be generated internally unless more control is desired:
Shipment
Orders can be fully or partially shipped, optionally with tracks.
Invoice
Orders can be fully or partially invoiced.
Credit Memo
Credit memos can be created for either all or some of the items ordered. An invoice to refund will be created internally.
Fixture pools
To manage multiple fixtures, fixture pools have been introduced for all entities:
Usage demonstrated with the ProductFixturePool
:
Config Fixtures
With the config fixture you can set a configuration value globally, i.e. it will ensure that it is not only set in the default scope but also in all store scopes:
It uses MutableScopeConfigInterface
, so the configuration is not persisted in the database. Use @magentoAppIsolation enabled
in your test to make sure that changes are reverted in subsequent tests.
You can also set configuration values explicitly for stores with ConfigFixture::setForStore()
Credits
- Fabian Schmengler
- All Contributors
License
The MIT License (MIT). Please see License File for more information.
All versions of magento2-fixtures with dependencies
magento/framework Version ^102.0|^103.0
magento/zendframework1 Version ^1.14
magento/module-catalog Version ^103.0|^104.0
magento/module-catalog-inventory Version ^100.3
magento/module-checkout Version ^100.3
magento/module-customer Version ^102.0|^103.0
magento/module-directory Version ^100.3
magento/module-indexer Version ^100.3
magento/module-payment Version ^100.3
magento/module-quote Version ^101.1
magento/module-sales Version ^102.0|^103.0
fakerphp/faker Version ^1.9.1