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 ChatApp\Tests; |
||
3 | |||
4 | use PHPUnit_Framework_TestCase; |
||
5 | use ChatApp\Login; |
||
6 | use ChatApp\Register; |
||
7 | use ChatApp\Profile; |
||
8 | use ChatApp\Validate; |
||
9 | use ChatApp\Online; |
||
10 | use ChatApp\User; |
||
11 | use Dotenv\Dotenv; |
||
12 | $dotenv = new Dotenv(dirname(__DIR__)); |
||
13 | $dotenv->load(); |
||
14 | |||
15 | class TestUser |
||
16 | extends |
||
17 | PHPUnit_Framework_TestCase |
||
18 | { |
||
19 | protected $obRegister; |
||
20 | protected $obLogin; |
||
21 | protected $obUser; |
||
22 | protected $obValidate; |
||
23 | |||
24 | |||
25 | public function setUp() |
||
26 | { |
||
27 | $this->obRegister = new Register(); |
||
28 | $this->obLogin = new Login(); |
||
29 | $this->obUser = new User(); |
||
30 | $this->obValidate = new Validate(); |
||
31 | } |
||
32 | |||
33 | |||
34 | View Code Duplication | public function test_authRegister() |
|
35 | { |
||
36 | |||
37 | $output = $this->obRegister->authRegister( |
||
38 | [ |
||
0 ignored issues
–
show
|
|||
39 | "name" => 'Test', |
||
40 | "email" => '[email protected]', |
||
41 | "username" => 'test', |
||
42 | "mob" => '1234567890', |
||
43 | "passRegister" => 'testing' |
||
44 | ] |
||
45 | ); |
||
46 | $output = (array)json_decode($output); |
||
47 | $this->assertEquals([ |
||
48 | 'location' => 'http://127.0.0.1/openchat/views/account.php' |
||
49 | ], $output); |
||
50 | |||
51 | } |
||
52 | |||
53 | /** |
||
54 | * @depends test_authRegister |
||
55 | * Testing for the register with empty username |
||
56 | */ |
||
57 | View Code Duplication | public function test_authregisterEmptyUsername() |
|
58 | { |
||
59 | $output = $this->obRegister->authregister( |
||
60 | [ |
||
0 ignored issues
–
show
array('name' => 'Test', ...Register' => 'testing') is of type array<string,string,{"na...assRegister":"string"}> , but the function expects a object .
It seems like the type of the argument is not accepted by the function/method which you are calling. In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug. We suggest to add an explicit type cast like in the following example: function acceptsInteger($int) { }
$x = '123'; // string "123"
// Instead of
acceptsInteger($x);
// we recommend to use
acceptsInteger((integer) $x);
![]() |
|||
61 | "name" => 'Test', |
||
62 | "email" => '[email protected]', |
||
63 | "username" => '', |
||
64 | "mob" => '1234567890', |
||
65 | "passRegister" => 'testing' |
||
66 | ] |
||
67 | ); |
||
68 | $output = (array)json_decode($output, True); |
||
69 | $expectedOutput = [ |
||
70 | [ |
||
71 | "key" => "username", |
||
72 | "value" => " *Enter the username" |
||
73 | ] |
||
74 | ]; |
||
75 | |||
76 | $this->assertEquals($expectedOutput, $output); |
||
77 | } |
||
78 | |||
79 | /** |
||
80 | * @depends test_authRegister |
||
81 | * Testing for the register with invalid email credentials |
||
82 | */ |
||
83 | View Code Duplication | public function test_authregisterInvalidEmail() |
|
84 | { |
||
85 | $output = $this->obRegister->authregister( |
||
86 | [ |
||
0 ignored issues
–
show
array('name' => 'Test', ...Register' => 'testing') is of type array<string,string,{"na...assRegister":"string"}> , but the function expects a object .
It seems like the type of the argument is not accepted by the function/method which you are calling. In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug. We suggest to add an explicit type cast like in the following example: function acceptsInteger($int) { }
$x = '123'; // string "123"
// Instead of
acceptsInteger($x);
// we recommend to use
acceptsInteger((integer) $x);
![]() |
|||
87 | "name" => 'Test', |
||
88 | "email" => '[email protected]', |
||
89 | "username" => 'abc', |
||
90 | "mob" => '1234567890', |
||
91 | "passRegister" => 'testing' |
||
92 | ] |
||
93 | ); |
||
94 | $output = (array)json_decode($output, True); |
||
95 | $expectedOutput = [ |
||
96 | [ |
||
97 | "key" => "email", |
||
98 | "value" => " *Enter correct Email address" |
||
99 | ] |
||
100 | ]; |
||
101 | |||
102 | $this->assertEquals($expectedOutput, $output); |
||
103 | } |
||
104 | |||
105 | /** |
||
106 | * @depends test_authRegister |
||
107 | * Testing for the register with repeated credentials |
||
108 | */ |
||
109 | public function test_authregisterInvalidCredentials() |
||
110 | { |
||
111 | $output = $this->obRegister->authregister( |
||
112 | [ |
||
0 ignored issues
–
show
array('name' => 'Test', ...Register' => 'testing') is of type array<string,string,{"na...assRegister":"string"}> , but the function expects a object .
It seems like the type of the argument is not accepted by the function/method which you are calling. In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug. We suggest to add an explicit type cast like in the following example: function acceptsInteger($int) { }
$x = '123'; // string "123"
// Instead of
acceptsInteger($x);
// we recommend to use
acceptsInteger((integer) $x);
![]() |
|||
113 | "name" => 'Test', |
||
114 | "email" => '[email protected]', |
||
115 | "username" => 'test', |
||
116 | "mob" => '1234567ese', |
||
117 | "passRegister" => 'testing' |
||
118 | ] |
||
119 | ); |
||
120 | $output = (array)json_decode($output, True); |
||
121 | $expectedOutput = [ |
||
122 | [ |
||
123 | "key" => "email", |
||
124 | "value" => " *Email is already registered" |
||
125 | ], |
||
126 | [ |
||
127 | "key" => "username", |
||
128 | "value" => " *Username is already registered" |
||
129 | ], |
||
130 | [ |
||
131 | "key" => "mob", |
||
132 | "value" => " *Enter correct Mobile Number" |
||
133 | ] |
||
134 | ]; |
||
135 | |||
136 | $this->assertEquals($expectedOutput, $output); |
||
137 | } |
||
138 | |||
139 | /** |
||
140 | * @depends test_authRegister |
||
141 | * Testing for the login with correct credentials |
||
142 | */ |
||
143 | public function test_authLogin() |
||
144 | { |
||
145 | $expectedOutput = ['location' => 'http://127.0.0.1/openchat/views/account.php']; |
||
146 | $outputEmail = $this->obLogin->authLogin( |
||
147 | [ |
||
148 | "login" => '[email protected]', |
||
149 | "passLogin" => 'testing' |
||
150 | ] |
||
151 | ); |
||
152 | $outputEmail = (array)json_decode($outputEmail); |
||
153 | $outputUsername = $this->obLogin->authLogin( |
||
154 | [ |
||
155 | "login" => 'test', |
||
156 | "passLogin" => 'testing' |
||
157 | ] |
||
158 | ); |
||
159 | $outputUsername = (array)json_decode($outputUsername); |
||
160 | $this->assertEquals($expectedOutput, $outputEmail); |
||
161 | $this->assertEquals($expectedOutput, $outputUsername); |
||
162 | } |
||
163 | |||
164 | /** |
||
165 | * @depends test_authRegister |
||
166 | * Testing for the login with empty credentials |
||
167 | */ |
||
168 | public function test_authLoginEmptyValues() |
||
169 | { |
||
170 | $output = $this->obLogin->authLogin( |
||
171 | [ |
||
172 | "login" => '', |
||
173 | "passLogin" => '' |
||
174 | ] |
||
175 | ); |
||
176 | $output = (array)json_decode($output, True); |
||
177 | $expectedOutput = [ |
||
178 | [ |
||
179 | "key" => "login", |
||
180 | "value" => " *Enter the login field" |
||
181 | ], |
||
182 | [ |
||
183 | "key" => "passLogin", |
||
184 | "value" => " *Enter the password" |
||
185 | ] |
||
186 | ]; |
||
187 | |||
188 | $this->assertEquals($expectedOutput, $output); |
||
189 | } |
||
190 | |||
191 | /** |
||
192 | * @depends test_authRegister |
||
193 | * Testing for the login with invalid or wrong email |
||
194 | */ |
||
195 | View Code Duplication | public function test_authLoginWrongEmail() |
|
196 | { |
||
197 | $output = $this->obLogin->authLogin( |
||
198 | [ |
||
199 | "login" => '[email protected]', |
||
200 | "passLogin" => 'egfb' |
||
201 | ] |
||
202 | ); |
||
203 | $output = (array)json_decode($output, True); |
||
204 | $expectedOutput = [ |
||
205 | [ |
||
206 | "key" => "login", |
||
207 | "value" => " *Enter correct Email address" |
||
208 | ] |
||
209 | ]; |
||
210 | |||
211 | $this->assertEquals($expectedOutput, $output); |
||
212 | } |
||
213 | |||
214 | /** |
||
215 | * @depends test_authRegister |
||
216 | * Testing for the login with invalid email credentials |
||
217 | */ |
||
218 | View Code Duplication | public function test_authLoginInvalidUsernameEmail() |
|
219 | { |
||
220 | $output = $this->obLogin->authLogin( |
||
221 | [ |
||
222 | "login" => 'invalid', |
||
223 | "passLogin" => 'invalid' |
||
224 | ] |
||
225 | ); |
||
226 | $output = (array)json_decode($output, True); |
||
227 | $expectedOutput = [ |
||
228 | [ |
||
229 | "key" => "login", |
||
230 | "value" => " *Invalid username or email" |
||
231 | ] |
||
232 | ]; |
||
233 | |||
234 | $this->assertEquals($expectedOutput, $output); |
||
235 | } |
||
236 | |||
237 | /** |
||
238 | * @depends test_authRegister |
||
239 | * Testing for the login with invalid password credentials |
||
240 | */ |
||
241 | View Code Duplication | public function test_authLoginInvalidPassword() |
|
242 | { |
||
243 | $output = $this->obLogin->authLogin( |
||
244 | [ |
||
245 | "login" => 'test', |
||
246 | "passLogin" => 'invalid' |
||
247 | ] |
||
248 | ); |
||
249 | $output = (array)json_decode($output, True); |
||
250 | $expectedOutput = [ |
||
251 | [ |
||
252 | "key" => "passLogin", |
||
253 | "value" => " *Invalid password" |
||
254 | ] |
||
255 | ]; |
||
256 | $this->assertEquals($expectedOutput, $output); |
||
257 | } |
||
258 | |||
259 | /** |
||
260 | * @depends test_authRegister |
||
261 | * Testing for the Profile::class with valid login_id |
||
262 | */ |
||
263 | public function test_getProfile() |
||
264 | { |
||
265 | $output = Profile::getProfile(1); |
||
266 | $this->assertEquals([ |
||
267 | 'login_id' => '1', |
||
268 | 'status' => 'Joined OpenChat', |
||
269 | 'education' => 'Joined OpenChat', |
||
270 | 'gender' => '' |
||
271 | ], $output); |
||
272 | } |
||
273 | |||
274 | /** |
||
275 | * @depends test_authRegister |
||
276 | * Testing for the Profile::class with invalid login_id |
||
277 | */ |
||
278 | public function test_getProfileInvalidID() |
||
279 | { |
||
280 | $output = Profile::getProfile(0); |
||
281 | $this->assertEquals(NULL, $output); |
||
282 | } |
||
283 | |||
284 | /** |
||
285 | * @depends test_authRegister |
||
286 | * Testing for the User::class with valid login_id |
||
287 | */ |
||
288 | public function test_userDetails() |
||
289 | { |
||
290 | $expectedOutput = [ |
||
291 | "login_id" => "1", |
||
292 | "name" => "Test", |
||
293 | "email" => "[email protected]", |
||
294 | "username"=> "test", |
||
295 | "mobile"=> "1234567890", |
||
296 | "login_status"=> "0" |
||
297 | ]; |
||
298 | |||
299 | $outputLoginId = $this->obUser->userDetails(1, True); |
||
0 ignored issues
–
show
True is of type boolean , but the function expects a object<ChatApp\boollen> .
It seems like the type of the argument is not accepted by the function/method which you are calling. In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug. We suggest to add an explicit type cast like in the following example: function acceptsInteger($int) { }
$x = '123'; // string "123"
// Instead of
acceptsInteger($x);
// we recommend to use
acceptsInteger((integer) $x);
![]() |
|||
300 | $outputUsername = $this->obUser->userDetails('test', False); |
||
0 ignored issues
–
show
False is of type boolean , but the function expects a object<ChatApp\boollen> .
It seems like the type of the argument is not accepted by the function/method which you are calling. In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug. We suggest to add an explicit type cast like in the following example: function acceptsInteger($int) { }
$x = '123'; // string "123"
// Instead of
acceptsInteger($x);
// we recommend to use
acceptsInteger((integer) $x);
![]() |
|||
301 | $this->assertEquals($expectedOutput, $outputLoginId); |
||
302 | $this->assertEquals($expectedOutput, $outputUsername); |
||
303 | } |
||
304 | |||
305 | /** |
||
306 | * @depends test_authRegister |
||
307 | * Testing for the User::class with invalid data |
||
308 | */ |
||
309 | public function test_userDetailsInvalidID() |
||
310 | { |
||
311 | $output = $this->obUser->userDetails(0, True); |
||
0 ignored issues
–
show
True is of type boolean , but the function expects a object<ChatApp\boollen> .
It seems like the type of the argument is not accepted by the function/method which you are calling. In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug. We suggest to add an explicit type cast like in the following example: function acceptsInteger($int) { }
$x = '123'; // string "123"
// Instead of
acceptsInteger($x);
// we recommend to use
acceptsInteger((integer) $x);
![]() |
|||
312 | $this->assertEquals(NULL, $output); |
||
313 | } |
||
314 | |||
315 | /** |
||
316 | * @depends test_authRegister |
||
317 | * Testing for the Validate::class for email |
||
318 | */ |
||
319 | public function test_validateEmailInDb() |
||
320 | { |
||
321 | $output = $this->obValidate->validateEmailInDb('[email protected]'); |
||
322 | $this->assertEquals(1, $output); |
||
323 | } |
||
324 | |||
325 | /** |
||
326 | * @depends test_authRegister |
||
327 | * Testing for the Validate::class for username |
||
328 | */ |
||
329 | public function test_validateUsernameInDb() |
||
330 | { |
||
331 | $output = $this->obValidate->validateUsernameInDb('test'); |
||
332 | $this->assertEquals(1, $output); |
||
333 | } |
||
334 | |||
335 | /** |
||
336 | * @depends test_authRegister |
||
337 | * Testing for the Validate::class for non-existing username |
||
338 | */ |
||
339 | public function test_validateUsernameInDbNot() |
||
340 | { |
||
341 | $output = $this->obValidate->validateUsernameInDb('abc'); |
||
342 | $this->assertEquals(0, $output); |
||
343 | } |
||
344 | |||
345 | /** |
||
346 | * @depends test_authRegister |
||
347 | * Testing for the Validate::class for non-existing email |
||
348 | */ |
||
349 | public function test_validateEmailInDbNot() |
||
350 | { |
||
351 | $output = $this->obValidate->validateEmailInDb('[email protected]'); |
||
352 | $this->assertEquals(0, $output); |
||
353 | } |
||
354 | |||
355 | /** |
||
356 | * @depends test_authRegister |
||
357 | * Testing for the Online::class |
||
358 | */ |
||
359 | public function test_Online() |
||
360 | { |
||
361 | Online::setOnlineStatus(1); |
||
362 | $output = $this->obUser->userDetails(1, True); |
||
0 ignored issues
–
show
True is of type boolean , but the function expects a object<ChatApp\boollen> .
It seems like the type of the argument is not accepted by the function/method which you are calling. In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug. We suggest to add an explicit type cast like in the following example: function acceptsInteger($int) { }
$x = '123'; // string "123"
// Instead of
acceptsInteger($x);
// we recommend to use
acceptsInteger((integer) $x);
![]() |
|||
363 | $output = $output['login_status']; |
||
364 | $this->assertEquals("1", $output); |
||
365 | Online::removeOnlineStatus(1); |
||
366 | $output = $this->obUser->userDetails(1, True); |
||
0 ignored issues
–
show
True is of type boolean , but the function expects a object<ChatApp\boollen> .
It seems like the type of the argument is not accepted by the function/method which you are calling. In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug. We suggest to add an explicit type cast like in the following example: function acceptsInteger($int) { }
$x = '123'; // string "123"
// Instead of
acceptsInteger($x);
// we recommend to use
acceptsInteger((integer) $x);
![]() |
|||
367 | $output = $output['login_status']; |
||
368 | $this->assertEquals("0", $output); |
||
369 | } |
||
370 | |||
371 | |||
372 | /** |
||
373 | * @depends test_Online |
||
374 | * Empty the DB |
||
375 | */ |
||
376 | public function test_EmptyDB() |
||
377 | { |
||
378 | $connect = mysqli_connect( |
||
379 | getenv('DB_HOST'), |
||
380 | getenv('DB_USER'), |
||
381 | getenv('DB_PASSWORD'), |
||
382 | getenv('DB_NAME') |
||
383 | ); |
||
384 | $query = "TRUNCATE `login`"; |
||
385 | $this->assertTrue($connect->query($query)); |
||
386 | $query = "TRUNCATE `profile`"; |
||
387 | $this->assertTrue($connect->query($query)); |
||
388 | $query = "TRUNCATE `register`"; |
||
389 | $this->assertTrue($connect->query($query)); |
||
390 | } |
||
391 | } |
||
392 | |||
393 |
It seems like the type of the argument is not accepted by the function/method which you are calling.
In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.
We suggest to add an explicit type cast like in the following example: