github.com/JesseHines0/factory-muffin ↗
Enables the rapid creation of objects for testing
Open this visualization on its own page →
Contributors
30
Lines of Code
1,616
From
2013-01-31
To
2020-12-13
About JesseHines0/factory-muffin
Factory Muffin is a PHP testing library that streamlines the creation of test objects by providing a factory pattern implementation inspired by Ruby's Factory Girl. It enables developers to quickly define and generate model instances for unit and integration tests without manually constructing each object.
The library allows developers to define factories for their models using a fluent API, specifying how attributes should be generated through various methods including custom closures, built-in generators, and integration with the Faker library for realistic test data. It supports creating unsaved instances for isolated testing or persisting objects to the database, handles relationships between models automatically, and provides seeding capabilities to generate multiple related objects at once.
Factory Muffin is designed for PHP 5.4+ projects and installed via Composer. It includes features like grouped model definitions for different testing scenarios, optional and unique attribute generation, creation callbacks, and automatic cleanup of generated test data. The package has integrations with CakePHP 3 and Yii 2 frameworks, making it adaptable to various PHP application architectures.