Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/Illuminate/Foundation/Bootstrap/LoadConfiguration.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
use Illuminate\Config\Repository;
use Illuminate\Contracts\Config\Repository as RepositoryContract;
use Illuminate\Contracts\Foundation\Application;
use Illuminate\Support\Collection;
use SplFileInfo;
use Symfony\Component\Finder\Finder;

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

foreach (array_diff(array_keys($base), array_keys($files)) as $name => $config) {
foreach ((new Collection($base))->diffKeys($files) as $name => $config) {
$repository->set($name, $config);
}

Expand Down
26 changes: 23 additions & 3 deletions tests/Foundation/Bootstrap/LoadConfigurationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace Illuminate\Tests\Foundation\Bootstrap;

use Illuminate\Filesystem\Filesystem;
use Illuminate\Foundation\Application;
use Illuminate\Foundation\Bootstrap\LoadConfiguration;
use PHPUnit\Framework\TestCase;
Expand All @@ -12,7 +13,7 @@ public function testLoadsBaseConfiguration()
{
$app = new Application();

(new LoadConfiguration())->bootstrap($app);
(new LoadConfiguration)->bootstrap($app);

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

(new LoadConfiguration())->bootstrap($app);
(new LoadConfiguration)->bootstrap($app);

$this->assertNull($app['config']['app.name']);
}
Expand All @@ -32,9 +33,28 @@ public function testLoadsConfigurationInIsolation()
$app = new Application(__DIR__.'/../fixtures');
$app->useConfigPath(__DIR__.'/../fixtures/config');

(new LoadConfiguration())->bootstrap($app);
(new LoadConfiguration)->bootstrap($app);

$this->assertNull($app['config']['bar.foo']);
$this->assertSame('bar', $app['config']['custom.foo']);
}

public function testConfigurationArrayKeysMatchLoadedFilenames()
{
$baseConfigPath = __DIR__.'/../../../config';
$customConfigPath = __DIR__.'/../fixtures/config';

$app = new Application();
$app->useConfigPath($customConfigPath);

(new LoadConfiguration)->bootstrap($app);

$this->assertEqualsCanonicalizing(
array_keys($app['config']->all()),
collect((new Filesystem)->files([
$baseConfigPath,
$customConfigPath,
]))->map(fn ($file) => $file->getBaseName('.php'))->unique()->values()->toArray()
);
}
}