Data Builders

Edit on GitHub

Data builders help you create transfer objects for your tests. Instead of preparing transfers each time you need them, data builders do the work for you. Data builders use the Faker library.

Data builders need to be configured only once, and then they are ready to use. The configuration is done within a module.databuilder.xml file that has to be placed into the _data directory.

Here is an example for a data builder configuration:

<?xml version="1.0"?>

    <transfer name="Customer">
        <property name="firstName" dataBuilderRule="firstName"/>


In your test, you will use the data builder with:

$customerTransfer = (new CustomerBuilder())->build();

With this code, you get CustomerTransfer that is filled by the Faker library with the defined dataBuilderRule(s). When passing the optional $seedData to the constructor, the values you pass will be used instead.