SignJsConnectTest   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 101
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 62
c 1
b 0
f 0
dl 0
loc 101
rs 10
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A testSignJsConnect() 0 2 1
B provideSignJsConnectTests() 0 79 1
1
<?php
2
/**
3
 * @author Alexandre (DaazKu) Chouinard <[email protected]>
4
 * @copyright 2009-2017 Vanilla Forums Inc.
5
 * @license GNU GPLv2 http://www.opensource.org/licenses/gpl-2.0.php
6
 */
7
8
namespace JsConnect\Tests;
9
10
/**
11
 * Unit tests signJsConnect
12
 */
13
class SignJsConnectTest extends \PHPUnit\Framework\TestCase {
0 ignored issues
show
Bug introduced by
The type PHPUnit\Framework\TestCase 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...
14
15
    /**
16
     * @param $data
17
     * @param $clientID
18
     * @param $secret
19
     * @param $hashType
20
     * @param $returnData
21
     * @param $expectedResult
22
     *
23
     * @dataProvider provideSignJsConnectTests
24
     */
25
    public function testSignJsConnect($data, $clientID, $secret, $hashType, $returnData, $expectedResult) {
26
        $this->assertEquals(signJsConnect($data, $clientID, $secret, $hashType, $returnData), $expectedResult);
27
    }
28
29
30
    /**
31
     * Provide signature to sign
32
     *
33
     * @return array Returns a test array.
34
     */
35
    public function provideSignJsConnectTests() {
36
        return [
37
            'default' => [
38
                [
39
                    'name' => 'John PHP',
40
                    'email' => '[email protected]',
41
                    'unique_id' => '123',
42
                ],
43
                'clientID',
44
                'secret',
45
                'sha256',
46
                false,
47
                '71528bfbb99aba97734f79beab6d1eca1416e05a0587e9ab55b99095753f74b6',
48
            ],
49
            'unordered' => [
50
                [
51
                    'unique_id' => '123',
52
                    'email' => '[email protected]',
53
                    'name' => 'John PHP',
54
                ],
55
                'clientID',
56
                'secret',
57
                'sha256',
58
                false,
59
                '71528bfbb99aba97734f79beab6d1eca1416e05a0587e9ab55b99095753f74b6',
60
            ],
61
            'incorrectKeyCase' => [
62
                [
63
                    'Name' => 'John PHP',
64
                    'eMail' => '[email protected]',
65
                    'UNIQUE_id' => '123',
66
                ],
67
                'clientID',
68
                'secret',
69
                'sha256',
70
                false,
71
                '71528bfbb99aba97734f79beab6d1eca1416e05a0587e9ab55b99095753f74b6',
72
            ],
73
            'trueAsHashType' => [
74
                [
75
                    'Name' => 'John PHP',
76
                    'eMail' => '[email protected]',
77
                    'unique_id' => '123',
78
                ],
79
                'clientID',
80
                'secret',
81
                true,
82
                false,
83
                'f1639a1838bd904cb967423be0567802',
84
            ],
85
            'extraInfo' => [
86
                [
87
                    'unique_id' => '123',
88
                    'email' => '[email protected]',
89
                    'name' => 'John PHP',
90
                    'custom_field' => 'custom',
91
                ],
92
                'clientID',
93
                'secret',
94
                'sha256',
95
                false,
96
                '72976aaaa96cb1acc94aa8c1638a0b3e10bb638e3985e25f60f6db79f65fcefb',
97
            ],
98
            'defaultReturnData' => [
99
                [
100
                    'name' => 'John PHP',
101
                    'email' => '[email protected]',
102
                    'unique_id' => '123',
103
                ],
104
                'clientID',
105
                'secret',
106
                'sha256',
107
                true,
108
                [
109
                    'name' => 'John PHP',
110
                    'email' => '[email protected]',
111
                    'unique_id' => '123',
112
                    'client_id' => 'clientID',
113
                    'sig' => '71528bfbb99aba97734f79beab6d1eca1416e05a0587e9ab55b99095753f74b6',
114
                ]
115
            ],
116
        ];
117
    }
118
}
119