diff --git a/composer.json b/composer.json index ccaea5f..4d9a119 100644 --- a/composer.json +++ b/composer.json @@ -42,7 +42,7 @@ "extra": { "laravel": { "providers": [ - "Staudenmeir\\EloquentHasManyDeep\\EloquentHasManyDeepServiceProvider" + "Staudenmeir\\EloquentHasManyDeep\\IdeHelperServiceProvider" ] } }, diff --git a/src/EloquentHasManyDeepServiceProvider.php b/src/IdeHelperServiceProvider.php similarity index 81% rename from src/EloquentHasManyDeepServiceProvider.php rename to src/IdeHelperServiceProvider.php index fe738c5..7763be1 100644 --- a/src/EloquentHasManyDeepServiceProvider.php +++ b/src/IdeHelperServiceProvider.php @@ -7,7 +7,7 @@ use Illuminate\Support\ServiceProvider; use Staudenmeir\EloquentHasManyDeep\IdeHelper\DeepRelationsHook; -class EloquentHasManyDeepServiceProvider extends ServiceProvider implements DeferrableProvider +class IdeHelperServiceProvider extends ServiceProvider implements DeferrableProvider { public function boot(): void { @@ -37,9 +37,13 @@ protected function registerIdeHelperHook(): void return; } - $config->set('ide-helper.model_hooks', array_merge([ - DeepRelationsHook::class, - ], $config->get('ide-helper.model_hooks', []))); + $config->set( + 'ide-helper.model_hooks', + array_merge( + [DeepRelationsHook::class], + $config->get('ide-helper.model_hooks', []) + ) + ); } protected function publishConfig(): void diff --git a/tests/EloquentHasManyDeepServiceProviderTest.php b/tests/IdeHelperServiceProviderTest.php similarity index 69% rename from tests/EloquentHasManyDeepServiceProviderTest.php rename to tests/IdeHelperServiceProviderTest.php index 32baaf4..a72da9d 100644 --- a/tests/EloquentHasManyDeepServiceProviderTest.php +++ b/tests/IdeHelperServiceProviderTest.php @@ -4,25 +4,18 @@ namespace Tests; -use Barryvdh\LaravelIdeHelper\IdeHelperServiceProvider; +use Barryvdh\LaravelIdeHelper\IdeHelperServiceProvider as BarryvdhIdeHelperServiceProvider; +use Illuminate\Foundation\Application; use Orchestra\Testbench\TestCase; +use Staudenmeir\EloquentHasManyDeep\IdeHelperServiceProvider; use Staudenmeir\EloquentHasManyDeep\IdeHelper\DeepRelationsHook; -use Staudenmeir\EloquentHasManyDeep\EloquentHasManyDeepServiceProvider; -class EloquentHasManyDeepServiceProviderTest extends TestCase +class IdeHelperServiceProviderTest extends TestCase { - protected function getPackageProviders($app): array - { - return [ - IdeHelperServiceProvider::class, - EloquentHasManyDeepServiceProvider::class, - ]; - } - public function testAutoRegistrationOfModelHook(): void { + $this->app->loadDeferredProvider(BarryvdhIdeHelperServiceProvider::class); $this->app->loadDeferredProvider(IdeHelperServiceProvider::class); - $this->app->loadDeferredProvider(EloquentHasManyDeepServiceProvider::class); /** @var \Illuminate\Contracts\Config\Repository $config */ $config = $this->app->get('config'); @@ -34,13 +27,12 @@ public function testAutoRegistrationOfModelHook(): void } /** - * @test * @define-env usesIdeHelperDisabledInConfig */ public function testDisabledRegistrationOfModelHookFromConfig(): void { + $this->app->loadDeferredProvider(BarryvdhIdeHelperServiceProvider::class); $this->app->loadDeferredProvider(IdeHelperServiceProvider::class); - $this->app->loadDeferredProvider(EloquentHasManyDeepServiceProvider::class); /** @var \Illuminate\Contracts\Config\Repository $config */ $config = $this->app->get('config'); @@ -51,8 +43,16 @@ public function testDisabledRegistrationOfModelHookFromConfig(): void ); } - protected function usesIdeHelperDisabledInConfig($app): void + protected function usesIdeHelperDisabledInConfig(Application $app): void { $app['config']->set('eloquent-has-many-deep.ide_helper_enabled', false); } + + protected function getPackageProviders($app): array + { + return [ + BarryvdhIdeHelperServiceProvider::class, + IdeHelperServiceProvider::class, + ]; + } }