1+ <?php
2+
3+ declare (strict_types=1 );
4+
5+ namespace PH7 \ApiSimpleMenu \Tests \Entity ;
6+
7+ use PH7 \ApiSimpleMenu \Entity \User as UserEntity ;
8+ use PHPUnit \Framework \TestCase ;
9+ use Ramsey \Uuid \Uuid ;
10+
11+ final class UserTest extends TestCase
12+ {
13+ private UserEntity $ userEntity ;
14+
15+ protected function setUp (): void
16+ {
17+ parent ::setUp ();
18+
19+ $ this ->userEntity = new UserEntity ();
20+ }
21+
22+ public function testSequentialId (): void
23+ {
24+ $ sequentialId = 55 ;
25+
26+ $ this ->userEntity ->setSequentialId ($ sequentialId );
27+
28+ $ this ->assertSame ($ sequentialId , $ this ->userEntity ->getSequentialId ());
29+ }
30+
31+ public function testUserUuid (): void
32+ {
33+ $ uuid = Uuid::uuid4 ()->toString ();
34+
35+ $ this ->userEntity ->setUserUuid ($ uuid );
36+
37+ $ this ->assertSame ($ uuid , $ this ->userEntity ->getUserUuid ());
38+ }
39+
40+ public function testUnserialize (): void
41+ {
42+ $ expectUserData = [
43+ 'id ' => 5 ,
44+ 'user_uuid ' => Uuid::uuid4 ()->toString (),
45+ 'first_name ' => 'Pierre ' ,
46+ 'last_name ' => 'Soria ' ,
47+ 'email ' => 'me@ph7.me ' ,
48+ 'phone ' => '043983934 ' ,
49+ 'password ' => 'chicken ' ,
50+ 'created_date ' => '2023-07-01 19:59:55 '
51+ ];
52+
53+ $ this ->userEntity ->unserialize ($ expectUserData );
54+
55+ // assertions
56+ $ this ->assertSame ($ expectUserData ['id ' ], $ this ->userEntity ->getSequentialId ());
57+ $ this ->assertSame ($ expectUserData ['user_uuid ' ], $ this ->userEntity ->getUserUuid ());
58+ $ this ->assertSame ($ expectUserData ['first_name ' ], $ this ->userEntity ->getFirstName ());
59+ $ this ->assertSame ($ expectUserData ['last_name ' ], $ this ->userEntity ->getLastName ());
60+ $ this ->assertSame ($ expectUserData ['email ' ], $ this ->userEntity ->getEmail ());
61+ $ this ->assertSame ($ expectUserData ['phone ' ], $ this ->userEntity ->getPhone ());
62+ $ this ->assertSame ($ expectUserData ['password ' ], $ this ->userEntity ->getPassword ());
63+ $ this ->assertSame ($ expectUserData ['created_date ' ], $ this ->userEntity ->getCreationDate ());
64+ }
65+ }
0 commit comments