1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
declare(strict_types=1); |
4
|
|
|
|
5
|
|
|
namespace RattfieldNz\SafeUrls\Tests\Libraries\Config; |
6
|
|
|
|
7
|
|
|
use RattfieldNz\SafeUrls\Libraries\Config\Config; |
8
|
|
|
use RattfieldNz\SafeUrls\Tests\TestCase; |
9
|
|
|
|
10
|
|
|
class ConfigTest extends TestCase |
11
|
|
|
{ |
12
|
|
|
|
13
|
|
|
protected function setUp(): void |
14
|
|
|
{ |
15
|
|
|
parent::setUp(); |
16
|
|
|
} |
17
|
|
|
|
18
|
|
|
/** |
19
|
|
|
* Test Google API key from config file. |
20
|
|
|
*/ |
21
|
|
|
public function testGoogleApiKey() |
22
|
|
|
{ |
23
|
|
|
$expected = env('GOOGLE_API_KEY'); |
24
|
|
|
$actual = Config::googleApiKey(); |
25
|
|
|
$this->assertEquals($expected, $actual); |
26
|
|
|
} |
27
|
|
|
|
28
|
|
|
/** |
29
|
|
|
* Test Google API Client Id from config file. |
30
|
|
|
*/ |
31
|
|
|
public function testClientId() |
32
|
|
|
{ |
33
|
|
|
$expected = env('GOOGLE_CLIENT_ID'); |
34
|
|
|
$actual = Config::clientId(); |
35
|
|
|
$this->assertEquals($expected, $actual); |
36
|
|
|
} |
37
|
|
|
|
38
|
|
|
/** |
39
|
|
|
* Test Google API Client Id from config file. |
40
|
|
|
*/ |
41
|
|
|
public function testClientVersion() |
42
|
|
|
{ |
43
|
|
|
$expected = env('GOOGLE_CLIENT_VERSION'); |
44
|
|
|
$actual = Config::clientVersion(); |
45
|
|
|
$this->assertEquals($expected, $actual); |
46
|
|
|
} |
47
|
|
|
|
48
|
|
|
/** |
49
|
|
|
* Test Google API Threat Types from config file. |
50
|
|
|
*/ |
51
|
|
|
public function testAllThreatTypes() |
52
|
|
|
{ |
53
|
|
|
|
54
|
|
|
$expected = [ |
55
|
|
|
'THREAT_TYPE_UNSPECIFIED', |
56
|
|
|
'MALWARE', |
57
|
|
|
'SOCIAL_ENGINEERING', |
58
|
|
|
'UNWANTED_SOFTWARE', |
59
|
|
|
'POTENTIALLY_HARMFUL_APPLICATION', |
60
|
|
|
]; |
61
|
|
|
|
62
|
|
|
$actual = Config::threatTypes(); |
63
|
|
|
$this->assertEquals($expected, $actual); |
64
|
|
|
} |
65
|
|
|
|
66
|
|
|
/** |
67
|
|
|
* Test Google API Platform Types from config file. |
68
|
|
|
*/ |
69
|
|
|
public function testAllPlatformTypes() |
70
|
|
|
{ |
71
|
|
|
|
72
|
|
|
$expected = [ |
73
|
|
|
'PLATFORM_TYPE_UNSPECIFIED', |
74
|
|
|
'WINDOWS', |
75
|
|
|
'LINUX', |
76
|
|
|
'ANDROID', |
77
|
|
|
'OSX', |
78
|
|
|
'IOS', |
79
|
|
|
'ANY_PLATFORM', |
80
|
|
|
'ALL_PLATFORMS', |
81
|
|
|
'CHROME', |
82
|
|
|
]; |
83
|
|
|
|
84
|
|
|
$actual = Config::platformTypes(); |
85
|
|
|
$this->assertEquals($expected, $actual); |
86
|
|
|
} |
87
|
|
|
|
88
|
|
|
/** |
89
|
|
|
* Test Google API Threat Entry Types from config file. |
90
|
|
|
*/ |
91
|
|
|
public function testAllThreatEntryTypes() |
92
|
|
|
{ |
93
|
|
|
|
94
|
|
|
$expected = [ |
95
|
|
|
'URL', |
96
|
|
|
'THREAT_ENTRY_TYPE_UNSPECIFIED', |
97
|
|
|
]; |
98
|
|
|
|
99
|
|
|
$actual = Config::threatEntryTypes(); |
100
|
|
|
$this->assertEquals($expected, $actual); |
101
|
|
|
} |
102
|
|
|
|
103
|
|
|
/** |
104
|
|
|
* Test Google API Curl Timeout from config file. |
105
|
|
|
*/ |
106
|
|
|
public function testCurlTimeout() |
107
|
|
|
{ |
108
|
|
|
|
109
|
|
|
$expected = env('GOOGLE_CURL_TIMEOUT'); |
110
|
|
|
$actual = Config::curlTimeout(); |
111
|
|
|
$this->assertEquals($expected, $actual); |
112
|
|
|
|
113
|
|
|
} |
114
|
|
|
|
115
|
|
|
} |
116
|
|
|
|