Search code examples
testingphpunitlumenfaker

Lumen 8 - Using Faker in tests makes InvalidArgumentException: Unknown format "name"


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,
        ];
    }

Solution

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

    $app->withFacades();
    
     $app->withEloquent();