Testomatio - Test Management for Codeception
If you use Codeception installed using composer, install this module with the following command:
Alternatively, you can enable
DataFactory module in suite configuration file and run
This module was bundled with Codeception 2 and 3, but since version 4 it is necessary to install it separately.
Some modules are bundled with PHAR files.
Warning. Using PHAR file and composer in the same project can cause unexpected errors.
DataFactory allows you to easily generate and create test data using FactoryMuffin. DataFactory uses an ORM of your application to define, save and cleanup data. Thus, should be used with ORM or Framework modules.
This module requires packages installed:
Generation rules can be defined in a factories file.
Create a folder for factories files:
Here is the sample factory file:
Configure this module to load factory definitions from a directory. You should also specify a module with an ORM as a dependency.
(you can also use Laravel and Phalcon).
In cases you want to use data from database inside your factory definitions you can define them in a Helper.
For instance, if you use Doctrine, this allows you to access
EntityManager inside a definition.
To proceed you should create Factories helper via
generate:helper command and enable it:
In this case you can define factories from a Helper class with
Factory Definitions are described in official Factory Muffin Documentation
If your module relies on other model you can generate them both.
To create a related module you can use either
entity prefix, depending on ORM you use.
In case your ORM expects an Id of a related record (Eloquent) to be set use
In case your ORM expects a related record itself (Doctrine) then you should use
You can define a custom store for Factory Muffin using
customStore parameter. It can be a simple class or a factory with
The instantiated object must implement
Store factory example:
Generates and saves a record,.
Returns an instance of created user.
Generates and saves a record multiple times.
Generates a record instance.
This does not save it in the database. Use
have for that.
Returns an instance of created user without creating a record in database.