JesseHines0/factory-muffin

Created Feb 22, 2021 · View the JesseHines0/factory-muffin repository page

Enables the rapid creation of objects for testing

Want this for your repo?

Render a free sample of any GitHub repo in seconds.

Visualize your own →

Contributors

30

Lines of Code

1,616

From

Jan 31, 2013

To

Dec 13, 2020

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.

Share this video