In laravel 5.8 app I make tests and adding new user for any tests I encountered that line
$loggedUser= factory(User::class)->create();
raise error :
Doctrine\DBAL\Driver\PDOException: SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry 'Username pariatur' for key 'users_username_unique'
with factory defined :
$factory->define(App\User::class, function (Faker $faker) {
$username= 'Username ' . $faker->word;
return [
'username' => $username,
I do not clear database, but how to make in series of tests get unqiue word for any test?