Home > Software design >  Lumen 8 - Using Faker in tests makes InvalidArgumentException: Unknown format "name"
Lumen 8 - Using Faker in tests makes InvalidArgumentException: Unknown format "name"

Time:12-28

I'm using Lumen default Tests only added this line to the test :

$users = \App\Models\User::factory()->count(5)->create();

But i get this error when running the test :

InvalidArgumentException: Unknown format "name"

I did't touch the UserFactory Class i include it below , whats wrong with my code?

public function definition()
    {
        return [
            'name' => $this->faker->name,
            'email' => $this->faker->unique()->safeEmail,
        ];
    }

CodePudding user response:

Uncommented these lines in app.php and its working now :

$app->withFacades();

 $app->withEloquent();

CodePudding user response:

You have to extend use Tests\TestCase instead of PHPUnit\Framework\TestCase.

At least, it helped me.

  • Related