Skip to content

Commit 16004f7

Browse files
committed
Correct how base options for missing config files are preloaded
1 parent d493d6f commit 16004f7

File tree

2 files changed

+22
-4
lines changed

2 files changed

+22
-4
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 & 3 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;
@@ -12,7 +13,7 @@ public function testLoadsBaseConfiguration()
1213
{
1314
$app = new Application();
1415

15-
(new LoadConfiguration())->bootstrap($app);
16+
(new LoadConfiguration)->bootstrap($app);
1617

1718
$this->assertSame('Laravel', $app['config']['app.name']);
1819
}
@@ -22,7 +23,7 @@ public function testDontLoadBaseConfiguration()
2223
$app = new Application();
2324
$app->dontMergeFrameworkConfiguration();
2425

25-
(new LoadConfiguration())->bootstrap($app);
26+
(new LoadConfiguration)->bootstrap($app);
2627

2728
$this->assertNull($app['config']['app.name']);
2829
}
@@ -32,9 +33,25 @@ public function testLoadsConfigurationInIsolation()
3233
$app = new Application(__DIR__.'/../fixtures');
3334
$app->useConfigPath(__DIR__.'/../fixtures/config');
3435

35-
(new LoadConfiguration())->bootstrap($app);
36+
(new LoadConfiguration)->bootstrap($app);
3637

3738
$this->assertNull($app['config']['bar.foo']);
3839
$this->assertSame('bar', $app['config']['custom.foo']);
3940
}
41+
42+
public function testConfigurationKeysAlignWithLoadedFiles()
43+
{
44+
$app = new Application();
45+
$app->useConfigPath(__DIR__.'/../fixtures/config');
46+
47+
(new LoadConfiguration)->bootstrap($app);
48+
49+
$this->assertEqualsCanonicalizing(
50+
array_keys($app['config']->all()),
51+
collect((new Filesystem)->files([
52+
__DIR__.'/../../../config',
53+
__DIR__.'/../fixtures/config',
54+
]))->map(fn ($file) => $file->getBaseName('.php'))->unique()->values()->toArray()
55+
);
56+
}
4057
}

0 commit comments

Comments
 (0)