Passed
Push — main ( 9cf148...e49e83 )
by José
11:57 queued 09:45
created

UserTest::testGetUrl()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 1
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 3
rs 10
1
<?php declare(strict_types=1);
2
3
namespace CrudSys\OAuth2\Client\Test\Entity;
4
5
use CrudSys\OAuth2\Client\Entity\User;
6
use PHPUnit\Framework\TestCase;
7
8
final class UserTest extends TestCase
9
{
10
    private User $user;
11
    private $response;
12
13
    protected function setUp(): void
14
    {
15
        $this->response = [
16
            'id' => 'garrykasparov',
17
            'username' => 'garrykasparov',
18
            'patron' => 0,
19
            'online' => 1,
20
            'profile' => [
21
                'country' => 'RU',
22
                'location' => 'Garik Kimovich Weinstein',
23
                'bio' => 'Russian chess grandmaster, former World Chess Champion, writer, political activist and commentator',
24
                'firstName' => 'Garry',
25
                'lastName' => 'Kasparov',
26
                'links' => 'https://twitter.com/garrykasparov'
27
            ],
28
            'url' => 'https://lichess.org/@/garrykasparov',
29
            'completionRate' => '100000',
30
        ];
31
32
        $this->user = new User($this->response);
33
    }
34
35
    public function testToArray(): void
36
    {
37
        $this->assertIsArray($this->user->toArray());
38
        $this->assertEquals($this->response, $this->user->toArray());
39
    }
40
41
    public function testGetId(): void
42
    {
43
        $this->assertEquals($this->response['id'], $this->user->getId());
44
    }
45
46
    public function testGetUsername(): void
47
    {
48
        $this->assertEquals($this->response['username'], $this->user->getUsername());
49
    }
50
51
    public function testIsPatron(): void
52
    {
53
        $this->assertFalse($this->user->isPatron());
54
    }
55
56
    public function testIsOnline(): void
57
    {
58
        $this->assertTrue($this->user->isOnline());
59
    }
60
61
    public function testGetCountry(): void
62
    {
63
        $this->assertEquals($this->response['profile']['country'], $this->user->getCountry());
64
    }
65
66
    public function testGetLocation(): void
67
    {
68
        $this->assertEquals($this->response['profile']['location'], $this->user->getLocation());
69
    }
70
71
    public function testGetBio(): void
72
    {
73
        $this->assertEquals($this->response['profile']['bio'], $this->user->getBio());
74
    }
75
76
    public function testGetFirstName(): void
77
    {
78
        $this->assertEquals($this->response['profile']['firstName'], $this->user->getFirstName());
79
    }
80
81
    public function testGetLastName(): void
82
    {
83
        $this->assertEquals($this->response['profile']['lastName'], $this->user->getLastName());
84
    }
85
86
    public function testGetLinks(): void
87
    {
88
        $this->assertEquals($this->response['profile']['links'], $this->user->getLinks());
89
    }
90
91
    public function testGetUrl(): void
92
    {
93
        $this->assertEquals($this->response['url'], $this->user->getUrl());
94
    }
95
96
    public function testGetCompletionRate(): void
97
    {
98
        $this->assertEquals($this->response['completionRate'], $this->user->getCompletionRate());
99
    }
100
}
101