Download the PHP package dansan/fixture-handler without Composer
On this page you can find all versions of the php package dansan/fixture-handler. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download dansan/fixture-handler
More information about dansan/fixture-handler
Files in dansan/fixture-handler
Package fixture-handler
Short Description A module to handle fixtures in tests
License MIT
Informations about the package fixture-handler
FixtureHandler
You can use FixtureHandler in your php test to compact your setup.
It is inspired by Doctrine Fixtures but FixtureHandler is not related only to the model or Doctrine entities.
It is inspired by the Symfony Dependency Injection Container but is not only a way to get services.
FixtureHandler allows you to save the references of data, models and services in a key-value registry.
It allows you to define some Fixtures and load them in a lazy way.
It allows you to define dependencies between Fixtures.
It allows you to define some Scenarios.
Getting started
Add FixtureHandler as dev requirement in your composer.json
Use it in a PHPUnit TestCase
How it works
The basic use is...
But it make sense to put the user instantiation into a Fixture...
...and add it to the FixtureHandler
You can define an item fixture depending on the users (not depending on the UserFixture)...
You don't need to add Fixture in the right order: FixtureHandler will load added fixture in the right order thanks to dependsOn() method.
dependsOn() method specifies the list of keys that load() method needs for the getRef() calls. Anyway if dependsOn() is not in sync with load() FixtureHandler will notify you the missing and exceeding keys so you can fix it.
You can create a Scenario, a special fixture depending on nothing, to add several fixtures or set some refs...
...so you can be ready in a few lines of code
About refs...
- you can set refs,
- you can get refs and specify a default,
- you can get refs and specify to trig an exception if they don't exist,
- you can check if refs exist.
You can use the trait in your TestCase...
Fixture loading will happen when you ask for a ref for the first time...
...but you can force the fixture loading
Why I should force the fixture loading? For example...
That's all!
Development
Clone the project:
Run cp .env.dist .env
and edit the .env
file properly.
The
dc
script will copy your ssh keys from your~/.ssh
dir into thephp
container.
Start te project and run the tests:
Credits
Thanks to Matiux for the Docker images used in the project