Finanzmanager/tests/36_ProfilPasswortTest.php

42 lines
1.1 KiB
PHP
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<?php
declare(strict_types=1);
use Finanzmanager\Models\Benutzer;
class ProfilPasswortTest extends TestCase
{
protected string $testName = 'Test 36: Profil – eigenes Passwort ändern';
public function run(): void
{
$this->passwortWirdGeaendert();
$this->altesPasswortWirdUngueltig();
}
private function passwortWirdGeaendert(): void
{
$name = 'test_' . bin2hex(random_bytes(4));
$id = Benutzer::anlegen($name, 'altespasswort123');
Benutzer::passwortSetzen($id, 'neuespasswort456');
$this->assertNotEmpty(
Benutzer::pruefeAnmeldung($name, 'neuespasswort456'),
'Anmeldung mit dem neuen Passwort gelingt'
);
}
private function altesPasswortWirdUngueltig(): void
{
$name = 'test_' . bin2hex(random_bytes(4));
$id = Benutzer::anlegen($name, 'altespasswort123');
Benutzer::passwortSetzen($id, 'neuespasswort456');
$this->assertNull(
Benutzer::pruefeAnmeldung($name, 'altespasswort123'),
'Anmeldung mit dem alten Passwort schlägt danach fehl'
);
}
}