From f165fc58ba9b62b76798fdf0f9330319bceb7afd Mon Sep 17 00:00:00 2001 From: Abrar Ahmad Date: Wed, 3 Aug 2022 12:28:38 +0500 Subject: [PATCH] register dumcommand when L8 --- src/TenancyServiceProvider.php | 8 +++++++- tests/CommandsTest.php | 14 ++++++++++++++ 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/src/TenancyServiceProvider.php b/src/TenancyServiceProvider.php index e23200a6..e6465b00 100644 --- a/src/TenancyServiceProvider.php +++ b/src/TenancyServiceProvider.php @@ -84,10 +84,16 @@ class TenancyServiceProvider extends ServiceProvider Commands\Migrate::class, Commands\Rollback::class, Commands\TenantList::class, - Commands\TenantDump::class, Commands\MigrateFresh::class, ]); + if (version_compare(app()->version(), '8.0', '>=')) { + // DumpCommand only exists since Laravel 8.0 or above + $this->commands([ + Commands\TenantDump::class, + ]); + } + $this->publishes([ __DIR__ . '/../assets/config.php' => config_path('tenancy.php'), ], 'config'); diff --git a/tests/CommandsTest.php b/tests/CommandsTest.php index 5172d752..de7d4303 100644 --- a/tests/CommandsTest.php +++ b/tests/CommandsTest.php @@ -76,6 +76,11 @@ test('migrate command works with tenants option', function () { }); test('migrate command loads schema state', function () { + if (! isVersion8()) { + $this->markTestSkipped('DumpCommand only exists since Laravel 8.0 or above'); + } + + $tenant = Tenant::create(); expect(Schema::hasTable('schema_users'))->toBeFalse(); @@ -94,6 +99,10 @@ test('migrate command loads schema state', function () { }); test('dump command works', function () { + if (! isVersion8()) { + $this->markTestSkipped('DumpCommand only exists since Laravel 8.0 or above'); + } + $tenant = Tenant::create(); Artisan::call('tenants:migrate'); @@ -210,3 +219,8 @@ function databaseConnectionSwitchedToDefault() expect(DB::connection()->getDatabaseName())->toBe($originalDBName); } + +function isVersion8(): bool +{ + return version_compare(app()->version(), '8.0', '>='); +}