Attainly/backend/tests/Unit/User/UserTest.php

39 lines
1 KiB
PHP

<?php
namespace Tests\Unit\User;
use App\Shared\ValueObject\EmailAddress;
use App\User\User;
use PHPUnit\Framework\TestCase;
class UserTest extends TestCase
{
public function test_it_exposes_its_identity_email_and_password_hash(): void
{
$email = new EmailAddress('user@example.com');
$user = new User(
id: 42,
email: $email,
passwordHash: 'hashed-password',
);
$this->assertSame(42, $user->getId());
$this->assertSame($email, $user->getEmail());
$this->assertSame('hashed-password', $user->getPasswordHash());
}
public function test_it_can_confirm_a_pending_user_with_a_password(): void
{
$user = new User(
id: 42,
email: new EmailAddress('user@example.com'),
passwordHash: null,
);
$this->assertNull($user->getPasswordHash());
$user->setPasswordHash('hashed-password');
$this->assertSame('hashed-password', $user->getPasswordHash());
}
}