Skip to content

Commit

Permalink
馃┕ Fix duplicate provider registration (#371)
Browse files Browse the repository at this point in the history
* 馃┕ Fix duplicate provider registration
  • Loading branch information
Log1x committed Apr 2, 2024
1 parent cacfc23 commit b4a0175
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/Roots/Acorn/DefaultProviders.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ public function __construct(?array $providers = null)
->filter(fn ($provider) => ! str_contains($provider, 'Illuminate\\Foundation\\'))
->push('Illuminate\\Foundation\\Providers\\ComposerServiceProvider')
->push('Illuminate\\Database\\MigrationServiceProvider')
->unique()
->all();
}
}
15 changes: 15 additions & 0 deletions tests/Application/DefaultProvidersTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?php

use Roots\Acorn\Tests\Test\Stubs\BootableServiceProvider;
use Roots\Acorn\Tests\Test\TestCase;

uses(TestCase::class);

it('dedupes registered providers', function () {
$providers = \Roots\Acorn\ServiceProvider::defaultProviders()->merge([
BootableServiceProvider::class,
BootableServiceProvider::class,
]);

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

0 comments on commit b4a0175

Please sign in to comment.