diff --git a/src/Illuminate/Foundation/Testing/WithFaker.php b/src/Illuminate/Foundation/Testing/WithFaker.php index eb1b67b0137e..fbcfc7687e30 100644 --- a/src/Illuminate/Foundation/Testing/WithFaker.php +++ b/src/Illuminate/Foundation/Testing/WithFaker.php @@ -3,6 +3,7 @@ namespace Illuminate\Foundation\Testing; use Faker\Factory; +use Faker\Generator; trait WithFaker { @@ -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); } }