Skip to content

Commit 8dee8c0

Browse files
authored
only rely on app's config() if app is set (#46529)
1 parent 5ab0bca commit 8dee8c0

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

src/Illuminate/Foundation/Testing/WithFaker.php

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,12 +43,14 @@ protected function faker($locale = null)
4343
*/
4444
protected function makeFaker($locale = null)
4545
{
46-
$locale ??= config('app.faker_locale', Factory::DEFAULT_LOCALE);
46+
if (isset($this->app)) {
47+
$locale ??= $this->app->make('config')->get('app.faker_locale', Factory::DEFAULT_LOCALE);
4748

48-
if (isset($this->app) && $this->app->bound(Generator::class)) {
49-
return $this->app->make(Generator::class, ['locale' => $locale]);
49+
if ($this->app->bound(Generator::class)) {
50+
return $this->app->make(Generator::class, ['locale' => $locale]);
51+
}
5052
}
5153

52-
return Factory::create($locale);
54+
return Factory::create($locale ?? Factory::DEFAULT_LOCALE);
5355
}
5456
}

0 commit comments

Comments
 (0)