AdminQueryTest   A
last analyzed

Complexity

Total Complexity 1

Size/Duplication

Total Lines 17
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Importance

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

1 Method

Rating   Name   Duplication   Size   Complexity  
A testQuery() 0 14 1
1
<?php
2
/**
3
 * Created by PhpStorm.
4
 * User: zjw
5
 * Date: 2017/8/17
6
 * Time: 下午4:16
7
 */
8
9
namespace yii\web;
10
11
use zacksleo\yii2\backend\models\Admin;
12
use zacksleo\yii2\backend\models\queries\AdminQuery;
13
use zacksleo\yii2\backend\tests\TestCase;
14
use yii;
15
16
class AdminQueryTest extends TestCase
17
{
18
    public function testQuery()
19
    {
20
        $modelClass = new Admin();
21
        $query = new AdminQuery($modelClass);
0 ignored issues
show
Documentation introduced by
$modelClass is of type object<zacksleo\yii2\backend\models\Admin>, but the function expects a string.

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);
Loading history...
22
        $query->init();
23
        $query->canLogin();
24
        $query->email("[email protected]");
25
        $query->username("lianluo");
26
        $this->assertTrue($query->count() > 0);
27
        $query->passwordResetToken("_" . time());
28
        $query->emailConfirmationToken("222_0");
29
30
        $this->assertFalse($query->count() > 0);
31
    }
32
}
33