Passed
Push — master ( 27dd3a...31fea7 )
by Alex
06:49 queued 02:55
created

VKAuthUnitTest   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 87
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 29
dl 0
loc 87
rs 10
c 0
b 0
f 0
wmc 5

5 Methods

Rating   Name   Duplication   Size   Complexity  
A testGetDesiredFields() 0 14 1
A testGetUerInfoUri() 0 7 1
A getSettings() 0 6 1
A testGetTokenUri() 0 7 1
A testDispatchUserInfo() 0 24 1
1
<?php
2
namespace Mezon\SocialNetwork\Auth\Tests;
3
4
use PHPUnit\Framework\TestCase;
5
6
class VKAuthUnitTest extends TestCase
7
{
8
9
    /**
10
     * Method returns fake settings
11
     *
12
     * @return array fake settings
13
     */
14
    protected function getSettings(): array
15
    {
16
        return ([
17
            'client_id' => 1,
18
            'client_secret' => 2,
19
            'redirect_uri' => 3
20
        ]);
21
    }
22
23
    /**
24
     * Testing getUserInfoUri
25
     */
26
    public function testGetUerInfoUri()
27
    {
28
        // setup
29
        $Auth = new \Mezon\SocialNetwork\Auth\Vkontakte($this->getSettings());
30
31
        // test body and assertions
32
        $this->assertStringContainsString('/api.vk.com/method/users.get?v=', $Auth->getUserInfoUri());
33
    }
34
35
    /**
36
     * Testing getTokenUri
37
     */
38
    public function testGetTokenUri()
39
    {
40
        // setup
41
        $Auth = new \Mezon\SocialNetwork\Auth\Vkontakte($this->getSettings());
42
43
        // test body and assertions
44
        $this->assertStringContainsString('/oauth.vk.com/access_token?v=', $Auth->getTokenUri());
45
    }
46
47
    /**
48
     * Testing getDesiredFields
49
     */
50
    public function testGetDesiredFields()
51
    {
52
        // setup
53
        $Auth = new \Mezon\SocialNetwork\Auth\Vkontakte($this->getSettings());
54
55
        // test body
56
        $Fields = $Auth->getDesiredFields();
57
58
        // assertions
59
        $this->assertStringContainsString('id', $Fields);
60
        $this->assertStringContainsString('first_name', $Fields);
61
        $this->assertStringContainsString('last_name', $Fields);
62
        $this->assertStringContainsString('email', $Fields);
63
        $this->assertStringContainsString('photo_100', $Fields);
64
    }
65
66
    /**
67
     * Testing dispatchUserInfo
68
     */
69
    public function testDispatchUserInfo()
70
    {
71
        // setup
72
        $Auth = new \Mezon\SocialNetwork\Auth\Vkontakte($this->getSettings());
73
74
        // test body
75
        $Result = $Auth->dispatchUserInfo([
76
            'response' => [
77
                [
78
                    'id' => '',
79
                    'first_name' => '',
80
                    'last_name' => '',
81
                    'photo_100' => '',
82
                    'email' => ''
83
                ]
84
            ]
85
        ]);
86
87
        // assertions
88
        $this->assertArrayHasKey('id', $Result, 'id was not found');
89
        $this->assertArrayHasKey('first_name', $Result, 'first_name was not found');
90
        $this->assertArrayHasKey('last_name', $Result, 'last_name was not found');
91
        $this->assertArrayHasKey('picture', $Result, 'picture was not found');
92
        $this->assertArrayHasKey('email', $Result, 'email was not found');
93
    }
94
}
95