Skip to content

Instantly share code, notes, and snippets.

@awgv
Last active December 21, 2017 09:23
Show Gist options
  • Save awgv/7a8110886cae4e37ffa586ab1f06c8c7 to your computer and use it in GitHub Desktop.
Save awgv/7a8110886cae4e37ffa586ab1f06c8c7 to your computer and use it in GitHub Desktop.
[Laravel] Use `Hash::setRounds(4)` in CreatesApplication trait to speed up your tests
<?php
/*
People are seeing test speeds improve by 15-55%.
Results will vary depending on how much user seeding and hasing your tests are doing.
Now included in laravel/laravel by default: https://github.com/laravel/laravel/pull/4517
*/
namespace Tests;
use Illuminate\Support\Facades\Hash;
use Illuminate\Contracts\Console\Kernel;
trait CreatesApplication
{
/**
* Creates the application.
*
* @return \Illuminate\Foundation\Application
*/
public function createApplication()
{
$app = require __DIR__.'/../bootstrap/app.php';
$app->make(Kernel::class)->bootstrap();
Hash::setRounds(5);
return $app;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment