From f01a387d1f9be040ffe872b35ac4d9e1aec6c6b9 Mon Sep 17 00:00:00 2001 From: Luke Kuzmish Date: Mon, 20 Mar 2023 14:24:50 -0400 Subject: [PATCH] only rely on app's config() if app is set --- src/Illuminate/Foundation/Testing/WithFaker.php | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/Illuminate/Foundation/Testing/WithFaker.php b/src/Illuminate/Foundation/Testing/WithFaker.php index 202a63e8c43b..592b50f0821b 100644 --- a/src/Illuminate/Foundation/Testing/WithFaker.php +++ b/src/Illuminate/Foundation/Testing/WithFaker.php @@ -43,12 +43,14 @@ protected function faker($locale = null) */ protected function makeFaker($locale = null) { - $locale ??= config('app.faker_locale', Factory::DEFAULT_LOCALE); + if (isset($this->app)) { + $locale ??= $this->app->make('config')->get('app.faker_locale', Factory::DEFAULT_LOCALE); - if (isset($this->app) && $this->app->bound(Generator::class)) { - return $this->app->make(Generator::class, ['locale' => $locale]); + if ($this->app->bound(Generator::class)) { + return $this->app->make(Generator::class, ['locale' => $locale]); + } } - return Factory::create($locale); + return Factory::create($locale ?? Factory::DEFAULT_LOCALE); } }