Compute hash only once and store in static variable
This commit is contained in:
parent
b041a03878
commit
792dcd48c8
|
@ -12,15 +12,12 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
$factory->define(App\User::class, function (Faker\Generator $faker) {
|
$factory->define(App\User::class, function (Faker\Generator $faker) {
|
||||||
|
static $password = null;
|
||||||
|
|
||||||
return [
|
return [
|
||||||
'name' => $faker->name,
|
'name' => $faker->name,
|
||||||
'email' => $faker->safeEmail,
|
'email' => $faker->safeEmail,
|
||||||
|
'password' => $password ?: $password = bcrypt('secret'),
|
||||||
// Use a precomputed hash of the word "secret" instead of using bcrypt directly.
|
|
||||||
// Since bcrypt is intentionally slow, it can really slow down test suites in
|
|
||||||
// large applications that use factories to generate models in many tests.
|
|
||||||
'password' => '$2y$10$oPCcCpaPQ69KQ1fdrAIL0eptYCcG/s/NmQZizJfVdB.QOXUn5mGE6',
|
|
||||||
|
|
||||||
'remember_token' => str_random(10),
|
'remember_token' => str_random(10),
|
||||||
];
|
];
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in New Issue