Passed
Pull Request — master (#305)
by Wilmer
04:05
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
declare(strict_types=1);
4
5
namespace tests\unit\models;
6
7
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...
8
9
final class UserTest extends \Codeception\Test\Unit
10
{
11
    public function testFindUserById(): void
12
    {
13
        verify($user = User::findIdentity(100))->notEmpty();
14
        verify($user->username)->equals('admin');
15
16
        verify(User::findIdentity(999))->empty();
17
    }
18
19
    public function testFindUserByAccessToken(): void
20
    {
21
        verify($user = User::findIdentityByAccessToken('100-token'))->notEmpty();
22
        verify($user->username)->equals('admin');
23
24
        verify(User::findIdentityByAccessToken('non-existing'))->empty();        
25
    }
26
27
    public function testFindUserByUsername(): void
28
    {
29
        verify($user = User::findByUsername('admin'))->notEmpty();
30
        verify(User::findByUsername('not-admin'))->empty();
31
    }
32
33
    /**
34
     * @depends testFindUserByUsername
35
     */
36
    public function testValidateUser(): void
37
    {
38
        $user = User::findByUsername('admin');
39
        verify($user->validateAuthKey('test100key'))->notEmpty();
40
        verify($user->validateAuthKey('test102key'))->empty();
41
42
        verify($user->validatePassword('admin'))->notEmpty();
43
        verify($user->validatePassword('123456'))->empty();        
44
    }
45
46
}
47