dereuromark / cakephp-fixture-factories
CakePHP Dynamic Fixtures
Installs: 5 603
Dependents: 0
Suggesters: 0
Security: 0
Stars: 1
Watchers: 0
Forks: 22
Open Issues: 1
Type:cakephp-plugin
pkg:composer/dereuromark/cakephp-fixture-factories
Requires
- php: >=8.2
- cakephp/orm: ^5.0
Requires (Dev)
- cakephp/bake: ^3.0.0
- cakephp/migrations: ^4.7.0 || ^5.0.0
- cakephp/twig-view: ^2.0.2
- fakerphp/faker: ^1.23
- johnykvsky/dummygenerator: ^0.1.0
- josegonzalez/dotenv: ^4.0.0
- php-collective/code-sniffer: dev-master
- phpstan/phpstan: ^2.1
- phpunit/phpunit: ^11.5 || ^12.5
- vierge-noire/cakephp-test-suite-light: ^3.0
README
CakePHP Fixture Factories
Write and run your tests faster. On any PHP application.
Note: This is a maintained fork of the original CakePHPFixtureFactories.
Main differences:
- Supports multiple generators via adapters (chose your generator library).
- Modern configurable generator type guessing per field name/type when baking.
Migrating from vierge-noire/cakephp-fixture-factories
If you're upgrading from vierge-noire/cakephp-fixture-factories:^3.0, the main breaking change is the generator type.
Callbacks in setDefaultTemplate() now receive GeneratorInterface instead of Faker\Generator:
- use Faker\Generator; + use CakephpFixtureFactories\Generator\GeneratorInterface; protected function setDefaultTemplate(): void { - $this->setDefaultData(function (Generator $faker) { + $this->setDefaultData(function (GeneratorInterface $generator) { return [ - 'email' => $faker->email, + 'email' => $generator->email(), ]; }); }
Key changes:
- Replace
Faker\Generatortype hints withGeneratorInterface - Use
$this->getGenerator()instead of deprecated$this->getFaker() - Prefer method calls
->email()over property access->email(both work)
See Generator Differences for details on the abstraction layer.
ArticleFactory::make(5) ->with('Authors[3].Address.City.Country') ->persist();
Installation
composer require --dev dereuromark/cakephp-fixture-factories
Content
-
Setup - DB Cleaning
-
Fixture Factories
-
Test Fixtures
-
Associations
-
Associations for non-CakePHP apps
-
Scenarios
-
Queries
-
Bake command
-
Persist command
-
Generator Abstraction
-
Configuration Reference
Resources
CakeFest 2021 - IPC-Berlin 2020 - CakeFest 2020
Contribute
Send PRs or tickets in GitHub.
Authors
Previously, Juan Pablo Ramirez and Nicolas Masson. This fork is maintained by Mark Scherer (dereuromark)
License
The CakePHPFixtureFactories plugin is offered under an MIT license.
Copyright 2023 Juan Pablo Ramirez and Nicolas Masson
Licensed under The MIT License Redistributions of files must retain the above copyright notice.