instances added god may help

This commit is contained in:
2026-02-23 12:58:19 +01:00
parent 25370a1a55
commit 99db252f60
290 changed files with 9858 additions and 4914 deletions

View File

@@ -2,32 +2,39 @@
namespace MintyPHP\Tests\Service;
use MintyPHP\Service\User\UserService;
use MintyPHP\Service\User\UserPasswordPolicyService;
use PHPUnit\Framework\TestCase;
class UserServicePasswordTest extends TestCase
{
private UserPasswordPolicyService $policy;
protected function setUp(): void
{
$this->policy = new UserPasswordPolicyService();
}
public function testRequiresPasswordWhenRequired(): void
{
$errors = UserService::validatePassword('', '', true, 'test@example.com');
$errors = $this->policy->validate('', '', true, 'test@example.com');
$this->assertNotEmpty($errors);
}
public function testRejectsMismatch(): void
{
$errors = UserService::validatePassword('Abcd1234$efg', 'Abcd1234$xxx', true, 'test@example.com');
$errors = $this->policy->validate('Abcd1234$efg', 'Abcd1234$xxx', true, 'test@example.com');
$this->assertNotEmpty($errors);
}
public function testAcceptsStrongPassword(): void
{
$errors = UserService::validatePassword('StrongPass1!', 'StrongPass1!', true, 'test@example.com');
$errors = $this->policy->validate('StrongPass1!', 'StrongPass1!', true, 'test@example.com');
$this->assertSame([], $errors);
}
public function testRejectsPasswordContainingEmail(): void
{
$errors = UserService::validatePassword('test@example.comA1!', 'test@example.comA1!', true, 'test@example.com');
$errors = $this->policy->validate('test@example.comA1!', 'test@example.comA1!', true, 'test@example.com');
$this->assertNotEmpty($errors);
}
}