lundi 21 août 2017

How to define a Laravel factory without a model?

Im controller testing and essentially want to define a factory to represent a post from the internet.

This post gets split up into several models in the controller.

I'm functional testing the whole controller though so how do I create a factory without a model to represent a front end post?

It appears factorys are made like this:

$factory->define(App\Models\User::class, function (Faker\Generator $faker) {

static $password;

return [
    'name' => $faker->name,
    'email' => $faker->unique()->safeEmail,
    'password' => $password ?: $password = bcrypt('secret'),
    'remember_token' => str_random(10),
    ];
});

Its the App\Models\User::class that's throwing me. I want a generic one that's not tied to the User model or any model.

Aucun commentaire:

Enregistrer un commentaire