Skip to content

Commit

Permalink
Merge pull request #30992 from ejunker/patch-1
Browse files Browse the repository at this point in the history
[6.x] Resolve Faker\Generator out of the container if it is bound
  • Loading branch information
taylorotwell committed Jan 1, 2020
2 parents cc3167d + c1a96b3 commit 50e43a5
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/Illuminate/Foundation/Testing/WithFaker.php
Expand Up @@ -3,6 +3,7 @@
namespace Illuminate\Foundation\Testing;

use Faker\Factory;
use Faker\Generator;

trait WithFaker
{
Expand Down Expand Up @@ -42,6 +43,12 @@ protected function faker($locale = null)
*/
protected function makeFaker($locale = null)
{
return Factory::create($locale ?? config('app.faker_locale', Factory::DEFAULT_LOCALE));
$locale = $locale ?? config('app.faker_locale', Factory::DEFAULT_LOCALE);

if ($this->app->bound(Generator::class)) {
return $this->app->make(Generator::class, [$locale]);
}

return Factory::create($locale);
}
}

0 comments on commit 50e43a5

Please sign in to comment.