Skip to content

Extended capabilities through Factory class + refactorings

Compare
Choose a tag to compare
@dwickstrom dwickstrom released this 02 May 15:00
· 10 commits to master since this release

I have done some quite refactorings like adding a Factory class, and placed all generated fixtures in a static array to be able to more freely handle the creation and deletion of models within the scope of a single request.

Here is what the Factory syntax looks like:

$model = Factory::times(3)->make('catalog/product');

You can also explicitly set a model that you want to be used as a dependency:

$customer = Mage::getModel('customer/customer')->load($customerId);
Factory::setFixture($customer);
Factory::make('customer/address');

Now your loaded customer will get the new address added to its address book.

Identifiers of all created models are stored in a text file, so that they can be deleted on the next request.

Fixture provider can also handle php type fixture files, which also has fzaninotto/Faker available for use.