fix: db exception in tests
This commit is contained in:
parent
5125862f80
commit
5a18d24464
|
|
@ -5,6 +5,8 @@ namespace App\Providers;
|
|||
use App\Models\Scope;
|
||||
use Illuminate\Foundation\Support\Providers\AuthServiceProvider as ServiceProvider;
|
||||
use Illuminate\Support\Facades\Cache;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
use Laravel\Passport\Passport;
|
||||
|
||||
class AuthServiceProvider extends ServiceProvider
|
||||
|
|
@ -40,7 +42,17 @@ class AuthServiceProvider extends ServiceProvider
|
|||
'ReportsManagement.ReadWrite' => 'auth.oauth.scope.reports-management.readwrite',
|
||||
];
|
||||
|
||||
$scopes = app()->runningConsoleCommand('package:discover') ? [] : Cache::rememberForever('scopes', function () {
|
||||
/*
|
||||
* Return empty scopes if running unit tests or before installation.
|
||||
* In these cases, migrations aren’t run yet, so DB queries will fail.
|
||||
* OAuth isn’t tested in unit tests, so returning empty scopes should be fine...?
|
||||
* Maybe the best approach is to run migrations before bootstrap in tests,
|
||||
* but this seems impossible for DB_DATABASE=:memory:;
|
||||
* Or change how scopes are registered so they don't depend on the database,
|
||||
* but that may introduce BREAKING CHANGES and plugin incompatibility.
|
||||
* PRs welcome for better solutions!
|
||||
*/
|
||||
$scopes = (app()->runningUnitTests() || !Storage::disk('root')->exists('storage/install.lock')) ? [] : Cache::rememberForever('scopes', function () {
|
||||
return Scope::pluck('description', 'name')->toArray();
|
||||
});
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user