magetest / manager
Magento fixture manager
Installs: 44 086
Dependents: 0
Suggesters: 0
Security: 0
Stars: 17
Watchers: 15
Forks: 11
Open Issues: 6
Requires
- php: >=5.3
- symfony/yaml: ~2.0
Requires (Dev)
- behat/mink: ~1.5.0
- behat/mink-goutte-driver: ~1.0.9
- magetest/magento: ~1.8.1.0
- phpspec/phpspec: ~2.0.1
- phpunit/phpunit: ~4.0.20
This package is not auto-updated.
Last update: 2024-12-17 08:21:29 UTC
README
Manager is a PHP library that manages test fixtures for a Magento site.
Fixtures
Manager takes YAML files as an input to create fixtures for a Magento test environment.
A YAML file maps to a Magento model via the key of the collection. The collection then maps to the model attributes of the defined Magento model.
Defining a model in a YAML file would look like this:
customer/customer: firstname: test lastname: test email: customer@example.com password: 123123pass website_id: 1 store: 1 status: 1
The most important part, is the key in the collection. This is the argument supplied to Mage::getModel()
.
After we define the fixture, all we need to do now is load it into the Manager.
<?php use MageTest\Manager\FixtureManager, MageTest\Manager\Attributes\Provider\YamlProvider; //init Manager and define attributes provider. Default is YAML $manager = new FixtureManager(new YamlProvider()); //Load fixture by model type into manager $manager->loadFixture('customer/customer'); //Use key defined in fixture file, to return instance of fixture model $customer = $manager->getFixture('customer/customer'); //Use customer model, change values/behaviour, assert data for acceptance tests //Delete all fixtures from Magento test environment DB $manager->clear();
Usage
This library can be used in conjunction with Behat (or any other acceptance/functional testing tool of choice). The flow could look something like this:
- Instantiate Manager before the scenario
- Before a feature, load required model(s) for acceptance test
- After the scenario, call
clear()
to clean up fixtures.
The aim is to keep the Step Defintions slim, and abstract away the DB interactions required to set up test data (think what Mink does as a web browser emulator abstraction).
Roadmap
- Default model builder.
- Add support for Configurable products, Bundled products
- Handle multiple instances of the same fixture.
- JSON, XML attribute providers.