Add manager:install, manager:doctor and an integration guide for AI agents
This commit is contained in:
1 parent
ebb5063ed1
commit
6f4d9b44f2
17 files changed
+388
-1
No files matched your search
@@ -0,0 +1,61 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Support\Facades\Artisan;
|
||||
use IriksIT\Manager\Support\ModuleRegistry;
|
||||
use IriksIT\Manager\Tests\TestCase;
|
||||
|
||||
uses(TestCase::class);
|
||||
|
||||
function doctorReport(): array
|
||||
{
|
||||
Artisan::call('manager:doctor', ['--json' => true]);
|
||||
|
||||
return json_decode(Artisan::output(), true);
|
||||
}
|
||||
|
||||
it('reports a healthy setup as JSON with exit code 0', function () {
|
||||
$report = doctorReport();
|
||||
$status = collect($report['checks'])->pluck('status', 'check');
|
||||
|
||||
expect($status['user_trait'])->toBe('ok')
|
||||
->and($status['tables'])->toBe('ok')
|
||||
->and($status['routes'])->toBe('ok')
|
||||
->and($report['ok'])->toBeTrue();
|
||||
});
|
||||
|
||||
it('fails with a fix when the user model is not a class', function () {
|
||||
config(['manager.user_model' => 'Nope\\User']);
|
||||
|
||||
$check = collect(doctorReport()['checks'])->firstWhere('check', 'user_model');
|
||||
|
||||
expect($check['status'])->toBe('fail')->and($check['fix'])->toContain('MANAGER_USER_MODEL');
|
||||
expect(Artisan::call('manager:doctor'))->toBe(1);
|
||||
});
|
||||
|
||||
it('warns when there is no super admin yet', function () {
|
||||
$check = collect(doctorReport()['checks'])->firstWhere('check', 'super_admin');
|
||||
|
||||
expect($check['status'])->toBe('warn')->and($check['fix'])->toContain('manager:create-user');
|
||||
});
|
||||
|
||||
it('lists the tables of the active modules', function () {
|
||||
$tables = collect(app(ModuleRegistry::class)->active())->flatMap->tables();
|
||||
|
||||
expect($tables)->toContain('media', 'posts');
|
||||
});
|
||||
|
||||
it('refuses an unknown module in the installer', function () {
|
||||
expect(Artisan::call('manager:install', ['--modules' => 'users,nonsense']))->toBe(1);
|
||||
});
|
||||
|
||||
it('writes the switches to .env', function () {
|
||||
$env = base_path('.env');
|
||||
$before = file_exists($env) ? file_get_contents($env) : null;
|
||||
|
||||
Artisan::call('manager:install', ['--modules' => 'users,media,posts', '--path' => 'admin']);
|
||||
|
||||
$written = file_get_contents($env);
|
||||
$before === null ? unlink($env) : file_put_contents($env, $before);
|
||||
|
||||
expect($written)->toContain('MANAGER_PATH=admin')->toContain('MANAGER_AUDIT=false')->toContain('MANAGER_POSTS=true');
|
||||
});
|
||||
Reference in new issue
Block a user