Skip to content

Commit 326f227

Browse files
committed
Correct how base options for missing config files are preloaded
1 parent 4f002b6 commit 326f227

File tree

2 files changed

+22
-1
lines changed

2 files changed

+22
-1
lines changed

src/Illuminate/Foundation/Bootstrap/LoadConfiguration.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
use Illuminate\Config\Repository;
66
use Illuminate\Contracts\Config\Repository as RepositoryContract;
77
use Illuminate\Contracts\Foundation\Application;
8+
use Illuminate\Support\Collection;
89
use SplFileInfo;
910
use Symfony\Component\Finder\Finder;
1011

@@ -69,7 +70,7 @@ protected function loadConfigurationFiles(Application $app, RepositoryContract $
6970
? $this->getBaseConfiguration()
7071
: [];
7172

72-
foreach (array_diff(array_keys($base), array_keys($files)) as $name => $config) {
73+
foreach (Collection::make($base)->diffKeys($files) as $name => $config) {
7374
$repository->set($name, $config);
7475
}
7576

tests/Foundation/Bootstrap/LoadConfigurationTest.php

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
namespace Illuminate\Tests\Foundation\Bootstrap;
44

5+
use Illuminate\Filesystem\Filesystem;
56
use Illuminate\Foundation\Application;
67
use Illuminate\Foundation\Bootstrap\LoadConfiguration;
78
use PHPUnit\Framework\TestCase;
@@ -37,4 +38,23 @@ public function testLoadsConfigurationInIsolation()
3738
$this->assertNull($app['config']['bar.foo']);
3839
$this->assertSame('bar', $app['config']['custom.foo']);
3940
}
41+
42+
public function testConfigurationArrayKeysMatchLoadedFilenames()
43+
{
44+
$baseConfigPath = __DIR__.'/../../../config';
45+
$customConfigPath = __DIR__.'/../fixtures/config';
46+
47+
$app = new Application();
48+
$app->useConfigPath($customConfigPath);
49+
50+
(new LoadConfiguration)->bootstrap($app);
51+
52+
$this->assertEqualsCanonicalizing(
53+
array_keys($app['config']->all()),
54+
collect((new Filesystem)->files([
55+
$baseConfigPath,
56+
$customConfigPath,
57+
]))->map(fn ($file) => $file->getBaseName('.php'))->unique()->values()->toArray()
58+
);
59+
}
4060
}

0 commit comments

Comments
 (0)