Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
4.35% |
1 / 23 |
|
50.00% |
1 / 2 |
CRAP | |
0.00% |
0 / 1 |
| short_ipv6__test | |
4.35% |
1 / 23 |
|
50.00% |
1 / 2 |
5.50 | |
0.00% |
0 / 1 |
| data_short_ipv6 | |
0.00% |
0 / 22 |
|
0.00% |
0 / 1 |
2 | |||
| test_short_ipv6 | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| 1 | <?php |
| 2 | /** |
| 3 | * |
| 4 | * This file is part of the phpBB Forum Software package. |
| 5 | * |
| 6 | * @copyright (c) phpBB Limited <https://www.phpbb.com> |
| 7 | * @license GNU General Public License, version 2 (GPL-2.0) |
| 8 | * |
| 9 | * For full copyright and license information, please see |
| 10 | * the docs/CREDITS.txt file. |
| 11 | * |
| 12 | */ |
| 13 | |
| 14 | class short_ipv6__test extends phpbb_test_case |
| 15 | { |
| 16 | public static function data_short_ipv6(): array |
| 17 | { |
| 18 | return [ |
| 19 | ['::1', 0, ''], |
| 20 | ['::1', 1, '0000:0000'], |
| 21 | ['::1', 2, '0000:0000:0000'], |
| 22 | ['::1', 3, '0000:0000:0000:0000'], |
| 23 | ['::1', 4, '0000:0000:0000:0000:0000:0000:0000:1'], |
| 24 | ['2001:db8:3333:4444:5555:6666:7777:8888', 0, ''], |
| 25 | ['2001:db8:3333:4444:5555:6666:7777:8888', 1, '2001:db8'], |
| 26 | ['2001:db8:3333:4444:5555:6666:7777:8888', 2, '2001:db8:3333'], |
| 27 | ['2001:db8:3333:4444:5555:6666:7777:8888', 3, '2001:db8:3333:4444'], |
| 28 | ['2001:db8:3333:4444:5555:6666:7777:8888', 4, '2001:db8:3333:4444:5555:6666:7777:8888'], |
| 29 | ['::ffff:192.168.1.1', 0, ''], |
| 30 | ['::ffff:192.168.1.1', 1, '0000:0000'], |
| 31 | ['::ffff:192.168.1.1', 2, '0000:0000:0000'], |
| 32 | ['::ffff:192.168.1.1', 3, '0000:0000:0000:0000'], |
| 33 | ['::ffff:192.168.1.1', 4, '0000:0000:0000:0000:0000:0000:ffff:192.168.1.1'], |
| 34 | ['FADE:BAD::192.168.0.1', 0, ''], |
| 35 | ['FADE:BAD::192.168.0.1', 1, 'fade:bad'], |
| 36 | ['FADE:BAD::192.168.0.1', 2, 'fade:bad:0000'], |
| 37 | ['FADE:BAD::192.168.0.1', 3, 'fade:bad:0000:0000'], |
| 38 | ['FADE:BAD::192.168.0.1', 4, 'fade:bad:0000:0000:0000:0000:c0a8:1'], |
| 39 | ]; |
| 40 | } |
| 41 | |
| 42 | /** |
| 43 | * @dataProvider data_short_ipv6 |
| 44 | */ |
| 45 | public function test_short_ipv6($ip, $length, $expected) |
| 46 | { |
| 47 | $this->assertEquals($expected, short_ipv6($ip, $length)); |
| 48 | } |
| 49 | } |