QuickQuiz/tests/Feature/InstallCommandTest.php

36 lines
1.1 KiB
PHP

<?php
declare(strict_types=1);
namespace Tests\Feature;
use App\Models\Permission;
use App\Models\User;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Illuminate\Support\Facades\Hash;
use Illuminate\Support\Facades\Storage;
use Tests\TestCase;
final class InstallCommandTest extends TestCase
{
use RefreshDatabase;
public function test_install_command_runs_seed_and_creates_admin_and_lock_file(): void
{
Storage::delete('installed.lock');
$this->artisan('quickquiz:install', [
'--admin-email' => 'owner@example.com',
'--admin-password' => 'owner-pass',
])->assertSuccessful();
$admin = User::query()->where('email', 'owner@example.com')->firstOrFail();
$this->assertSame('admin', $admin->role);
$this->assertTrue(Hash::check('owner-pass', $admin->password));
$this->assertTrue(Storage::exists('installed.lock'));
$this->assertDatabaseHas('system_settings', ['key' => 'site.name']);
$this->assertTrue(Permission::query()->where('code', 'banks')->exists());
}
}