1 | <?php |
||
20 | class UserTest extends TestCaseAbstract |
||
21 | { |
||
22 | /** |
||
23 | * setUp |
||
24 | * |
||
25 | * @since 4.0.0 |
||
26 | */ |
||
27 | |||
28 | public function setUp() : void |
||
29 | { |
||
30 | parent::setUp(); |
||
31 | $installer = $this->installerFactory(); |
||
32 | $installer->init(); |
||
33 | $installer->rawCreate(); |
||
34 | Db::forTablePrefix('users') |
||
35 | ->create() |
||
36 | ->set( |
||
37 | [ |
||
38 | 'name' => 'Test One', |
||
39 | 'user' => 'testOne', |
||
40 | 'password' => 'testOne', |
||
41 | 'email' => '[email protected]' |
||
42 | ]) |
||
43 | ->save(); |
||
44 | Db::forTablePrefix('users') |
||
45 | ->create() |
||
46 | ->set( |
||
47 | [ |
||
48 | 'name' => 'Test Two', |
||
49 | 'user' => 'testTwo', |
||
50 | 'password' => 'testTwo', |
||
51 | 'email' => '[email protected]' |
||
52 | ]) |
||
53 | ->save(); |
||
54 | } |
||
55 | |||
56 | /** |
||
57 | * tearDown |
||
58 | * |
||
59 | * @since 4.0.0 |
||
60 | */ |
||
61 | |||
62 | public function tearDown() : void |
||
63 | { |
||
64 | $this->dropDatabase(); |
||
65 | } |
||
66 | |||
67 | /** |
||
68 | * testGetByUser |
||
69 | * |
||
70 | * @since 4.0.0 |
||
71 | * |
||
72 | * @param string $user |
||
73 | * @param int $expect |
||
74 | * |
||
75 | * @dataProvider providerAutoloader |
||
76 | */ |
||
77 | |||
78 | public function testGetByUser(string $user = null, int $expect = null) : void |
||
79 | { |
||
80 | /* setup */ |
||
81 | |||
82 | $userModel = new Model\User(); |
||
83 | |||
84 | /* actual */ |
||
85 | |||
86 | $actual = $userModel->getByUser($user)?->id; |
||
|
|||
87 | |||
88 | /* compare */ |
||
89 | |||
90 | $this->assertEquals($expect, $actual); |
||
91 | } |
||
92 | |||
93 | /** |
||
94 | * testGetByEmail |
||
95 | * |
||
96 | * @since 5.0.0 |
||
97 | * |
||
98 | * @param string $email |
||
99 | * @param int $expect |
||
100 | * |
||
101 | * @dataProvider providerAutoloader |
||
102 | */ |
||
103 | |||
104 | public function testGetByEmail(string $email = null, int $expect = null) : void |
||
105 | { |
||
106 | /* setup */ |
||
107 | |||
108 | $userModel = new Model\User(); |
||
109 | |||
110 | /* actual */ |
||
111 | |||
112 | $actual = $userModel->getByEmail($email)?->id; |
||
113 | |||
114 | /* compare */ |
||
115 | |||
116 | $this->assertEquals($expect, $actual); |
||
117 | } |
||
118 | |||
119 | /** |
||
120 | * testCreateByArray |
||
121 | * |
||
122 | * @since 4.0.0 |
||
123 | * |
||
124 | * @param array $createArray |
||
125 | * @param bool $expect |
||
126 | * |
||
127 | * @dataProvider providerAutoloader |
||
128 | */ |
||
129 | |||
130 | public function testCreateByArray(array $createArray = [], bool $expect = null) : void |
||
131 | { |
||
132 | /* setup */ |
||
133 | |||
134 | $userModel = new Model\User(); |
||
135 | |||
136 | /* actual */ |
||
137 | |||
138 | $actual = $userModel->createByArray($createArray); |
||
139 | |||
140 | /* compare */ |
||
141 | |||
142 | $this->assertEquals($expect, $actual); |
||
143 | } |
||
144 | |||
145 | /** |
||
146 | * testResetPasswordById |
||
147 | * |
||
173 |