GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.
Completed
Push — master ( fed686...61a1e4 )
by Rob
03:18
created

DataTest::testFormatUrlsSingle()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 10
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 5
c 0
b 0
f 0
nc 1
nop 0
dl 0
loc 10
rs 10
1
<?php
2
3
declare(strict_types=1);
4
5
namespace RattfieldNz\SafeUrls\Libraries\Data;
6
7
use RattfieldNz\SafeUrls\Libraries\Config\Config;
8
use RattfieldNz\SafeUrls\Tests\TestCase;
9
10
class DataTest extends TestCase
11
{
12
    private $formattedUrls = [
13
        ['url' => 'https://www.google.com'],
14
        ['url' => 'https://github.com'],
15
        ['url' => 'https://github.styleci.io'],
16
        ['url' => 'https://travis-ci.org'],
17
        ['url' => 'https://packagist.org'],
18
    ];
19
20
    private $urls = [
21
        'https://www.google.com',
22
        'https://github.com',
23
        'https://github.styleci.io',
24
        'https://travis-ci.org',
25
        'https://packagist.org'
26
    ];
27
28
    protected function setUp(): void
29
    {
30
        parent::setUp();
31
    }
32
33
    public function testPayloadMultipleUrls()
34
    {
35
        $expected = [
36
            'client' => [
37
                'clientId' => Config::clientId(),
38
                'clientVersion' => Config::clientVersion(),
39
            ],
40
            'threatInfo' => [
41
                "threatTypes" => Config::threatTypes(),
42
                "platformTypes" => Config::platformTypes(),
43
                "threatEntryTypes" => Config::threatEntryTypes(),
44
                "threatEntries" => $this->formattedUrls,
45
            ]
46
        ];
47
48
        $actual = Data::payload($this->urls);
49
        $this->assertEquals($expected, $actual);
50
    }
51
52
    public function testPayloadSingleUrl(){
53
        $formattedUrl = [
54
            ['url' => 'https://www.google.com'],
55
        ];
56
57
        $url = [
58
            'https://www.google.com',
59
        ];
60
61
        $expected = [
62
            'client' => [
63
                'clientId' => Config::clientId(),
64
                'clientVersion' => Config::clientVersion(),
65
            ],
66
            'threatInfo' => [
67
                "threatTypes" => Config::threatTypes(),
68
                "platformTypes" => Config::platformTypes(),
69
                "threatEntryTypes" => Config::threatEntryTypes(),
70
                "threatEntries" => $formattedUrl,
71
            ]
72
        ];
73
74
        $actual = Data::payload($url);
75
        $this->assertEquals($expected, $actual);
76
    }
77
78
    public function testPayloadNoUrls(){
79
        $formattedUrls = [
80
            //['url' => ''],
81
        ];
82
83
        $urls = [];
84
85
        $expected = [
86
            'client' => [
87
                'clientId' => Config::clientId(),
88
                'clientVersion' => Config::clientVersion(),
89
            ],
90
            'threatInfo' => [
91
                "threatTypes" => Config::threatTypes(),
92
                "platformTypes" => Config::platformTypes(),
93
                "threatEntryTypes" => Config::threatEntryTypes(),
94
                "threatEntries" => $formattedUrls,
95
            ]
96
        ];
97
98
        $actual = Data::payload($urls);
99
        $this->assertEquals($expected, $actual);
100
    }
101
102
    public function testFormatUrlsMultiple(){
103
104
        $expected = $this->formattedUrls;
105
106
        $actual = Data::formatUrls($this->urls);
107
        $this->assertEquals($expected, $actual);
108
    }
109
110
    public function testFormatUrlsSingle(){
111
112
        $url = ['https://www.google.com'];
113
114
        $expected = [
115
            ['url' => 'https://www.google.com']
116
        ];
117
118
        $actual = Data::formatUrls($url);
119
        $this->assertEquals($expected, $actual);
120
    }
121
122
    public function testFormatUrlsNone(){
123
124
        $urls = [];
125
126
        $expected = [];
127
128
        $actual = Data::formatUrls($urls);
129
        $this->assertEquals($expected, $actual);
130
    }
131
}
132