UserTest::testFindUserByAccessToken()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 3
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 6
rs 10
1
<?php
2
3
namespace tests\unit\models;
4
5
use app\models\User;
6
7
class UserTest extends \Codeception\Test\Unit
0 ignored issues
show
Bug introduced by
The type Codeception\Test\Unit was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
8
{
9
    public function testFindUserById()
10
    {
11
        expect_that($user = User::findIdentity(100));
0 ignored issues
show
Bug introduced by
The function expect_that was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

11
        /** @scrutinizer ignore-call */ 
12
        expect_that($user = User::findIdentity(100));
Loading history...
12
        expect($user->username)->equals('admin');
0 ignored issues
show
Bug introduced by
The function expect was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

12
        /** @scrutinizer ignore-call */ 
13
        expect($user->username)->equals('admin');
Loading history...
Bug introduced by
Accessing username on the interface yii\web\IdentityInterface suggest that you code against a concrete implementation. How about adding an instanceof check?
Loading history...
13
14
        expect_not(User::findIdentity(999));
0 ignored issues
show
Bug introduced by
The function expect_not was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

14
        /** @scrutinizer ignore-call */ 
15
        expect_not(User::findIdentity(999));
Loading history...
15
    }
16
17
    public function testFindUserByAccessToken()
18
    {
19
        expect_that($user = User::findIdentityByAccessToken('100-token'));
0 ignored issues
show
Bug introduced by
The function expect_that was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

19
        /** @scrutinizer ignore-call */ 
20
        expect_that($user = User::findIdentityByAccessToken('100-token'));
Loading history...
20
        expect($user->username)->equals('admin');
0 ignored issues
show
Bug introduced by
The function expect was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

20
        /** @scrutinizer ignore-call */ 
21
        expect($user->username)->equals('admin');
Loading history...
Bug introduced by
Accessing username on the interface yii\web\IdentityInterface suggest that you code against a concrete implementation. How about adding an instanceof check?
Loading history...
21
22
        expect_not(User::findIdentityByAccessToken('non-existing'));        
0 ignored issues
show
Bug introduced by
The function expect_not was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

22
        /** @scrutinizer ignore-call */ 
23
        expect_not(User::findIdentityByAccessToken('non-existing'));        
Loading history...
23
    }
24
25
    public function testFindUserByUsername()
26
    {
27
        expect_that($user = User::findByUsername('admin'));
0 ignored issues
show
introduced by
The method findByUsername() does not exist on app\models\User. Maybe you want to declare this class abstract? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

27
        expect_that($user = User::/** @scrutinizer ignore-call */ findByUsername('admin'));
Loading history...
Bug introduced by
The function expect_that was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

27
        /** @scrutinizer ignore-call */ 
28
        expect_that($user = User::findByUsername('admin'));
Loading history...
28
        expect_not(User::findByUsername('not-admin'));
0 ignored issues
show
Bug introduced by
The function expect_not was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

28
        /** @scrutinizer ignore-call */ 
29
        expect_not(User::findByUsername('not-admin'));
Loading history...
29
    }
30
31
    /**
32
     * @depends testFindUserByUsername
33
     */
34
    public function testValidateUser($user)
35
    {
36
        $user = User::findByUsername('admin');
37
        expect_that($user->validateAuthKey('test100key'));
0 ignored issues
show
Bug introduced by
The function expect_that was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

37
        /** @scrutinizer ignore-call */ 
38
        expect_that($user->validateAuthKey('test100key'));
Loading history...
38
        expect_not($user->validateAuthKey('test102key'));
0 ignored issues
show
Bug introduced by
The function expect_not was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

38
        /** @scrutinizer ignore-call */ 
39
        expect_not($user->validateAuthKey('test102key'));
Loading history...
39
40
        expect_that($user->validatePassword('admin'));
41
        expect_not($user->validatePassword('123456'));        
42
    }
43
44
}
45