Files
ludikevent_crm/tests/Service/Generator/TempPasswordGeneratorTest.php
Serreau Jovann 0be752c145 ```
 feat(revervation): [Ajoute la création de session de réservation et le flow]
🐛 fix(PurgeCommandTest): [Utilise addCommand au lieu de add pour les commandes]
📝 chore(deps): [Mise à jour des dépendances Composer et corrections]
🐛 fix(KeycloakAuthenticator): [Corrige le type nullable de l'exception start]
 feat(Customer): [Ajoute les sessions de commandes aux entités Customer]
♻️ refactor(AppLogger): [Refactorise l'AppLogger pour obtenir l'UserAgent]
 feat(FlowReserve): [Ajoute une action de validation du panier]
```
2026-01-31 13:49:25 +01:00

74 lines
2.1 KiB
PHP

<?php
namespace App\Tests\Service\Generator;
use App\Service\Generator\TempPasswordGenerator;
use PHPUnit\Framework\TestCase;
class TempPasswordGeneratorTest extends TestCase
{
public function testGenerateDefaultLength(): void
{
$password = TempPasswordGenerator::generate();
$this->assertEquals(12, strlen($password));
}
public function testGenerateCustomLength(): void
{
$length = 16;
$password = TempPasswordGenerator::generate($length);
$this->assertEquals($length, strlen($password));
}
public function testGenerateInvalidLength(): void
{
$password = TempPasswordGenerator::generate(-5);
$this->assertEquals(12, strlen($password)); // Should fallback to default
}
public function testGenerateCustomCharacters(): void
{
$chars = 'ABC';
$password = TempPasswordGenerator::generate(10, $chars);
$this->assertEquals(10, strlen($password));
$this->assertMatchesRegularExpression('/^[ABC]+$/', $password);
}
public function testIsComplexValid(): void
{
// Needs 8+ chars, Upper, Lower, Digit, Special
$password = 'Ab1!defg';
$this->assertTrue(TempPasswordGenerator::isComplex($password));
}
public function testIsComplexTooShort(): void
{
$password = 'Ab1!de'; // 6 chars
$this->assertFalse(TempPasswordGenerator::isComplex($password));
}
public function testIsComplexMissingUpper(): void
{
$password = 'ab1!defg';
$this->assertFalse(TempPasswordGenerator::isComplex($password));
}
public function testIsComplexMissingLower(): void
{
$password = 'AB1!DEFG';
$this->assertFalse(TempPasswordGenerator::isComplex($password));
}
public function testIsComplexMissingDigit(): void
{
$password = 'Abc!defg';
$this->assertFalse(TempPasswordGenerator::isComplex($password));
}
public function testIsComplexMissingSpecial(): void
{
$password = 'Ab12defg';
$this->assertFalse(TempPasswordGenerator::isComplex($password));
}
}