Skip to content

Commit

Permalink
🩹 Fix default provider discrepancies (#385)
Browse files Browse the repository at this point in the history
  • Loading branch information
Log1x authored Jul 16, 2024
2 parents e42873b + a324c53 commit 7b8b7ef
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/Roots/Acorn/DefaultProviders.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ class DefaultProviders extends DefaultProvidersBase
*/
protected array $disallowedProviders = [
\Illuminate\Foundation\Providers\ConsoleSupportServiceProvider::class,
\Illuminate\View\ViewServiceProvider::class,
];

/**
Expand All @@ -43,6 +44,12 @@ public function __construct(?array $providers = null)
{
parent::__construct($providers);

$this->providers = array_unique($this->providers);

if ($providers) {
return;
}

$this->providers = Collection::make($this->providers)
->merge($this->acornProviders)
->filter(fn ($provider) => ! Str::contains($provider, $this->disallowedProviders))
Expand Down
11 changes: 11 additions & 0 deletions tests/Application/DefaultProvidersTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,14 @@

expect($providers->toArray())->toBe(array_unique($providers->toArray()));
});

it('replaces default providers', function () {
$providers = \Roots\Acorn\ServiceProvider::defaultProviders()->replace([
\Roots\Acorn\Providers\AcornServiceProvider::class => BootableServiceProvider::class,
]);

expect($providers->toArray())
->toContain(BootableServiceProvider::class)
->not()
->toContain(\Roots\Acorn\Providers\AcornServiceProvider::class);
});

0 comments on commit 7b8b7ef

Please sign in to comment.