This project does not seem to handle request data directly as such no vulnerable execution paths were found.
include
, or for example
via PHP's auto-loading mechanism.
These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
1 | <?php |
||
2 | namespace Redaxscript\Tests\Model; |
||
3 | |||
4 | use Redaxscript\Db; |
||
5 | use Redaxscript\Model; |
||
6 | use Redaxscript\Tests\TestCaseAbstract; |
||
7 | |||
8 | /** |
||
9 | * UserTest |
||
10 | * |
||
11 | * @since 4.0.0 |
||
12 | * |
||
13 | * @package Redaxscript |
||
14 | * @category Tests |
||
15 | * @author Henry Ruhs |
||
16 | * |
||
17 | * @covers Redaxscript\Model\User |
||
18 | */ |
||
19 | |||
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; |
||
0 ignored issues
–
show
Bug
introduced
by
Loading history...
|
|||
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 | * |
||
148 | * @since 4.0.0 |
||
149 | * |
||
150 | * @param int $userId |
||
151 | * @param string $password |
||
152 | * @param string $expect |
||
153 | * |
||
154 | * @dataProvider providerAutoloader |
||
155 | */ |
||
156 | |||
157 | public function testResetPasswordById(int $userId = null, string $password = null, string $expect = null) : void |
||
158 | { |
||
159 | /* setup */ |
||
160 | |||
161 | $userModel = new Model\User(); |
||
162 | $userModel->resetPasswordById($userId, $password); |
||
163 | |||
164 | /* actual */ |
||
165 | |||
166 | $actual = $userModel->query()->whereIdIs($userId)->findOne()->password; |
||
167 | |||
168 | /* compare */ |
||
169 | |||
170 | $this->assertEquals($expect, $actual); |
||
171 | } |
||
172 | } |
||
173 |