Files
breadcrumb-the-shire/tests/Service/UserServicePasswordTest.php

34 lines
1020 B
PHP
Raw Normal View History

2026-02-04 23:31:53 +01:00
<?php
namespace MintyPHP\Tests\Service;
2026-02-11 19:28:12 +01:00
use MintyPHP\Service\User\UserService;
2026-02-04 23:31:53 +01:00
use PHPUnit\Framework\TestCase;
class UserServicePasswordTest extends TestCase
{
public function testRequiresPasswordWhenRequired(): void
{
$errors = UserService::validatePassword('', '', true, 'test@example.com');
2026-02-04 23:31:53 +01:00
$this->assertNotEmpty($errors);
}
public function testRejectsMismatch(): void
{
$errors = UserService::validatePassword('Abcd1234$efg', 'Abcd1234$xxx', true, 'test@example.com');
2026-02-04 23:31:53 +01:00
$this->assertNotEmpty($errors);
}
public function testAcceptsStrongPassword(): void
{
$errors = UserService::validatePassword('StrongPass1!', 'StrongPass1!', true, 'test@example.com');
2026-02-04 23:31:53 +01:00
$this->assertSame([], $errors);
}
public function testRejectsPasswordContainingEmail(): void
{
$errors = UserService::validatePassword('test@example.comA1!', 'test@example.comA1!', true, 'test@example.com');
2026-02-04 23:31:53 +01:00
$this->assertNotEmpty($errors);
}
}