Some checks failed
CI / PHP 8.4 / mariadb:10.6 (pull_request) Successful in 1m14s
CI / PHP 8.3 / mariadb:10.6 (pull_request) Successful in 1m16s
CI / PHP 8.3 / mariadb:11.4 (pull_request) Successful in 1m17s
CI / PHP 8.4 / mariadb:11.4 (pull_request) Successful in 1m17s
CI / PHP 8.3 / mysql:8.0 (pull_request) Failing after 1m21s
CI / PHP 8.4 / mysql:8.0 (pull_request) Failing after 1m19s
CI / PHP 8.3 / mysql:8.4 (pull_request) Failing after 1m14s
CI / PHP 8.4 / mysql:8.4 (pull_request) Failing after 1m12s
CI / Build-Artefakte aktuell (pull_request) Successful in 52s
- Nach der Einrichtung Erfolgsmeldung auf der Anmeldeseite (per Parameter, da die Sitzung beim Wechsel auf den Datenbank-Speicher verloren geht) - Root-.htaccess für Hoster ohne einstellbaren Webroot: leitet intern nach public/, .env und Programmdateien bleiben unerreichbar - Begrüßungskarte: Namen nicht mehr abschneiden; Personenzahl mit korrekter Einzahl - docs/INSTALLATION.md für Kunden: Voraussetzungen, Einrichtung, Cron, Updates - CI: vendor-Vergleich ohne composer/installed.php (enthält den Projekt-Commit) Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
117 lines
4.6 KiB
PHP
117 lines
4.6 KiB
PHP
<?php
|
|
|
|
namespace Tests\Feature;
|
|
|
|
use App\Models\User;
|
|
use App\Support\Installation;
|
|
use App\Support\License\LicenseStore;
|
|
use App\Support\Settings;
|
|
use App\Support\Update\Filesystem;
|
|
use Illuminate\Foundation\Testing\RefreshDatabase;
|
|
use Tests\TestCase;
|
|
|
|
class InstallerTest extends TestCase
|
|
{
|
|
use RefreshDatabase;
|
|
|
|
private string $dir;
|
|
|
|
protected function setUp(): void
|
|
{
|
|
parent::setUp();
|
|
|
|
$this->dir = sys_get_temp_dir().'/inhaus-inst-'.bin2hex(random_bytes(4));
|
|
mkdir($this->dir);
|
|
copy(base_path('.env.example'), $this->dir.'/.env');
|
|
$this->app->useEnvironmentPath($this->dir);
|
|
$this->app->instance(LicenseStore::class, new LicenseStore($this->dir.'/license.json'));
|
|
config(['inhaus.installed' => false]);
|
|
}
|
|
|
|
protected function tearDown(): void
|
|
{
|
|
@unlink(storage_path('.installed'));
|
|
Filesystem::deleteDirectory($this->dir);
|
|
|
|
parent::tearDown();
|
|
}
|
|
|
|
public function test_every_page_leads_to_the_installer(): void
|
|
{
|
|
$this->get('/')->assertRedirect('/install');
|
|
$this->get('/login')->assertRedirect('/install');
|
|
$this->get('/install')->assertOk()->assertSee('Systemprüfung')->assertSee('PHP-Version');
|
|
}
|
|
|
|
public function test_wrong_database_credentials_are_explained(): void
|
|
{
|
|
$this->post('/install/datenbank', [
|
|
'host' => config('database.connections.mysql.host'),
|
|
'port' => config('database.connections.mysql.port'),
|
|
'database' => config('database.connections.mysql.database'),
|
|
'username' => 'gibtesnicht',
|
|
'password' => 'falsch',
|
|
])->assertSessionHasErrors(['host' => 'Verbindung fehlgeschlagen: Benutzername oder Passwort sind falsch, oder der Benutzer hat keinen Zugriff auf diese Datenbank.']);
|
|
}
|
|
|
|
public function test_database_settings_are_written_to_env(): void
|
|
{
|
|
$this->post('/install/datenbank', [
|
|
'host' => config('database.connections.mysql.host'),
|
|
'port' => config('database.connections.mysql.port'),
|
|
'database' => config('database.connections.mysql.database'),
|
|
'username' => config('database.connections.mysql.username'),
|
|
'password' => config('database.connections.mysql.password'),
|
|
])->assertRedirect('/install/konto');
|
|
|
|
$env = file_get_contents($this->dir.'/.env');
|
|
$this->assertStringContainsString('DB_DATABASE='.config('database.connections.mysql.database'), $env);
|
|
$this->assertStringContainsString('DB_USERNAME='.config('database.connections.mysql.username'), $env);
|
|
$this->assertStringContainsString('APP_URL='.url('/'), $env);
|
|
}
|
|
|
|
public function test_account_step_completes_the_installation(): void
|
|
{
|
|
$this->post('/install/konto', [
|
|
'portal_name' => 'Caritas-Netz',
|
|
'first_name' => 'Ada',
|
|
'last_name' => 'Admin',
|
|
'email' => 'Ada@Example.com',
|
|
'password' => 'SicheresPasswort1',
|
|
'password_confirmation' => 'SicheresPasswort1',
|
|
'license_email' => 'lizenz@example.com',
|
|
'license_key' => 'KEY-123',
|
|
])->assertRedirect('/login?eingerichtet=1');
|
|
|
|
$admin = User::query()->where('email', 'ada@example.com')->sole();
|
|
$this->assertTrue($admin->is_admin);
|
|
$this->assertSame('Ada Admin', $admin->name);
|
|
$this->assertSame('Caritas-Netz', app(Settings::class)->get('branding.portal_name'));
|
|
$this->assertSame('KEY-123', app(LicenseStore::class)->key());
|
|
$this->assertFileExists(storage_path('.installed'));
|
|
|
|
config(['inhaus.installed' => null]);
|
|
$this->assertTrue(Installation::isInstalled());
|
|
$this->get('/install')->assertNotFound();
|
|
$this->get('/login?eingerichtet=1')->assertInertia(fn ($page) => $page
|
|
->where('status', 'Die Einrichtung ist abgeschlossen. Sie können sich jetzt mit Ihrem Administratorkonto anmelden.'));
|
|
}
|
|
|
|
public function test_weak_admin_password_is_rejected(): void
|
|
{
|
|
$this->post('/install/konto', [
|
|
'portal_name' => 'Portal', 'first_name' => 'A', 'last_name' => 'B', 'email' => 'a@example.com',
|
|
'password' => 'kurz', 'password_confirmation' => 'kurz',
|
|
])->assertSessionHasErrors('password');
|
|
|
|
$this->assertFileDoesNotExist(storage_path('.installed'));
|
|
}
|
|
|
|
public function test_installer_is_gone_once_installed(): void
|
|
{
|
|
config(['inhaus.installed' => true]);
|
|
|
|
$this->get('/install')->assertNotFound();
|
|
$this->post('/install/konto', [])->assertNotFound();
|
|
}
|
|
}
|