This document will cover how to use a Behat specific API to setup a site for testing. What this includes is setting up a Scenario so that it has the data you need to run a test. This makes it possible not to rely on Seed data for this. This will allow us to run behat tests from remote machines as well as run tests in parallel.

Why not seed data?

From experience seed data fails in two ways.

One a project gets large and there is a ton of seed data and one person adds to it or alters in a way that effects how someone else was expecting the data to be. It just becomes too much of it's own domain of knowledge outside of the test it applies to.

Second seed data assumes you can reset the state of the application at anytime. But if you want to run your tests in parallel you need to have a more precise system to set up the "World" for that particular Scenario.


First we will setup an API in our app just for Behat and the behat user.

Example Route protected by Authentication as a particular user.

    ['as' => 'behat.camp_eu', 'uses' => '\AlfredNutileInc\BehatAPI\[email protected]']);

Example Controller

public function setEUCampaignToPushed()
    $campaign = Campaign::find($this->campaign_id_eu);

        $campaign->status = Campaign::PUSHED;

So now our data is set.