ResetPasswordFormTest   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 28
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Importance

Changes 0
Metric Value
dl 0
loc 28
rs 10
c 0
b 0
f 0
wmc 3
lcom 0
cbo 3

1 Method

Rating   Name   Duplication   Size   Complexity  
A testResetPassword() 0 25 3
1
<?php
2
/**
3
 * Created by PhpStorm.
4
 * User: zjw
5
 * Date: 2017/8/17
6
 * Time: 下午5:34
7
 */
8
9
namespace zacksleo\yii2\backend\tests;
10
11
use zacksleo\yii2\backend\models\Admin;
12
use zacksleo\yii2\backend\models\forms\ResetPasswordForm;
13
14
class ResetPasswordFormTest extends TestCase
15
{
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('');
0 ignored issues
show
Unused Code introduced by
$form is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

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.

Loading history...
32
        } catch (\yii\base\InvalidParamException $e) {
33
            $this->assertTrue($e instanceof \yii\base\InvalidParamException);
34
        }
35
        try {
36
            $form = new ResetPasswordForm('zxcvbfd');
0 ignored issues
show
Unused Code introduced by
$form is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

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.

Loading history...
37
        } catch (\yii\base\InvalidParamException $e) {
38
            $this->assertTrue($e instanceof \yii\base\InvalidParamException);
39
        }
40
    }
41
}
42