Conditions | 3 |
Paths | 4 |
Total Lines | 25 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
1 | <?php |
||
16 | public function testResetPassword() |
||
17 | { |
||
18 | $model = Admin::findOne(['id' => 1]); |
||
19 | $model->generatePasswordResetToken(true); |
||
20 | $form = new ResetPasswordForm($model->getAttribute('password_reset_token')); |
||
21 | $form->password = "lianluo"; |
||
22 | $form->validate(); |
||
23 | $this->assertTrue($form->resetPassword()); |
||
24 | $model->generatePasswordResetToken(true); |
||
25 | $form->password = "1!an1u0"; |
||
26 | $form->validate(); |
||
27 | $this->assertTrue($form->resetPassword()); |
||
28 | $model->generatePasswordResetToken(true); |
||
29 | |||
30 | try { |
||
31 | $form = new ResetPasswordForm(''); |
||
|
|||
32 | } catch (\yii\base\InvalidParamException $e) { |
||
33 | $this->assertTrue($e instanceof \yii\base\InvalidParamException); |
||
34 | } |
||
35 | try { |
||
36 | $form = new ResetPasswordForm('zxcvbfd'); |
||
37 | } catch (\yii\base\InvalidParamException $e) { |
||
38 | $this->assertTrue($e instanceof \yii\base\InvalidParamException); |
||
39 | } |
||
40 | } |
||
41 | } |
||
42 |
This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.
Both the
$myVar
assignment in line 1 and the$higher
assignment in line 2 are dead. The first because$myVar
is never used and the second because$higher
is always overwritten for every possible time line.