Passed
Pull Request — master (#305)
by Wilmer
14:19
created

UserTest::testFindUserById()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 3
dl 0
loc 6
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
1
<?php
2
3
namespace tests\unit\models;
4
5
use app\models\User;
0 ignored issues
show
Bug introduced by
The type app\models\User 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...
6
7
class UserTest extends \Codeception\Test\Unit
8
{
9
    public function testFindUserById()
10
    {
11
        verify($user = User::findIdentity(100))->notEmpty();
12
        verify($user->username)->equals('admin');
13
14
        verify(User::findIdentity(999))->empty();
15
    }
16
17
    public function testFindUserByAccessToken()
18
    {
19
        verify($user = User::findIdentityByAccessToken('100-token'))->notEmpty();
20
        verify($user->username)->equals('admin');
21
22
        verify(User::findIdentityByAccessToken('non-existing'))->empty();        
23
    }
24
25
    public function testFindUserByUsername()
26
    {
27
        verify($user = User::findByUsername('admin'))->notEmpty();
28
        verify(User::findByUsername('not-admin'))->empty();
29
    }
30
31
    /**
32
     * @depends testFindUserByUsername
33
     */
34
    public function testValidateUser()
35
    {
36
        $user = User::findByUsername('admin');
37
        verify($user->validateAuthKey('test100key'))->notEmpty();
38
        verify($user->validateAuthKey('test102key'))->empty();
39
40
        verify($user->validatePassword('admin'))->notEmpty();
41
        verify($user->validatePassword('123456'))->empty();        
42
    }
43
44
}
45