vendredi 4 mars 2016

Lumen 5.1 seeding with output from tests

To be able to run the integration tests with database testing I wrote a seeder, that seeds Messages table with fake messages for a fake, newly created user. This user's ID is then required to retrieve the messages, so inside the seeder class I simply print its ID.

Then in a test I call the following:

$output = new BufferedOutput;
$exitCode = \Artisan::call('db:seed', ['--class' => UserMessagesSeeder'], $output);

This should let me retrieve the output with the following:

$output->fetch()

However the above always returns null.

Is there something I'm doing wrong? Or perhaps there is a better way to call a seeder? Should I simply include the entire factory to my testing class and call it when necessary? It seems cumbersome, to be fair.

Aucun commentaire:

Enregistrer un commentaire