Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
76.00% |
19 / 25 |
|
66.67% |
2 / 3 |
CRAP | |
0.00% |
0 / 1 |
| phpbb_functions_user_whois_test | |
76.00% |
19 / 25 |
|
66.67% |
2 / 3 |
3.12 | |
0.00% |
0 / 1 |
| setUp | |
100.00% |
14 / 14 |
|
100.00% |
1 / 1 |
1 | |||
| ips_data | |
0.00% |
0 / 6 |
|
0.00% |
0 / 1 |
2 | |||
| test_ip_whois | |
100.00% |
5 / 5 |
|
100.00% |
1 / 1 |
1 | |||
| 1 | <?php |
| 2 | /** |
| 3 | * |
| 4 | * @package testing |
| 5 | * @copyright (c) 2020 phpBB Group |
| 6 | * @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2 |
| 7 | * |
| 8 | */ |
| 9 | |
| 10 | require_once __DIR__ . '/../../phpBB/includes/functions_user.php'; |
| 11 | |
| 12 | class phpbb_functions_user_whois_test extends phpbb_test_case |
| 13 | { |
| 14 | public function setUp(): void |
| 15 | { |
| 16 | global $config, $phpbb_dispatcher, $user, $request, $symfony_request, $phpbb_root_path, $phpEx; |
| 17 | |
| 18 | $user = $this->getMockBuilder('\phpbb\user') |
| 19 | ->setConstructorArgs([ |
| 20 | new \phpbb\language\language(new \phpbb\language\language_file_loader($phpbb_root_path, $phpEx)), |
| 21 | '\phpbb\datetime', |
| 22 | ]) |
| 23 | ->getMock(); |
| 24 | $phpbb_dispatcher = new phpbb_mock_event_dispatcher(); |
| 25 | $config = new \phpbb\config\config([]); |
| 26 | $request = $this->getMockBuilder('\phpbb\request\request') |
| 27 | ->getMock(); |
| 28 | $symfony_request = $this->getMockBuilder('\phpbb\symfony_request') |
| 29 | ->disableOriginalConstructor() |
| 30 | ->getMock(); |
| 31 | } |
| 32 | |
| 33 | public static function ips_data() |
| 34 | { |
| 35 | return [ |
| 36 | ['2001:4860:4860::8888'], // Google public DNS (ARIN) |
| 37 | ['64.233.161.139'], // google.com (ARIN) |
| 38 | ['1.1.1.1'], // Cloudflare (APNIC via whois:// referral) |
| 39 | ['213.133.116.44'], // Hetzner (RIPE via non-whois:// referral) |
| 40 | ]; |
| 41 | } |
| 42 | |
| 43 | /** |
| 44 | * @dataProvider ips_data |
| 45 | */ |
| 46 | public function test_ip_whois($ip) |
| 47 | { |
| 48 | $ip_whois = user_ipwhois($ip); |
| 49 | $this->assertStringNotContainsString('Query terms are ambiguous', $ip_whois); |
| 50 | $this->assertStringNotContainsString('no entries found', $ip_whois); |
| 51 | $this->assertStringNotContainsString('ERROR', $ip_whois); |
| 52 | $this->assertStringNotContainsString('Allocated to RIPE NCC', $ip_whois); // This only shows if the referral isn't found |
| 53 | } |
| 54 | } |