Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
10.53% |
2 / 19 |
|
66.67% |
2 / 3 |
CRAP | |
0.00% |
0 / 1 |
| phpbb_filesystem_helper_clean_path_test | |
10.53% |
2 / 19 |
|
66.67% |
2 / 3 |
9.45 | |
0.00% |
0 / 1 |
| setUp | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| clean_path_data | |
0.00% |
0 / 17 |
|
0.00% |
0 / 1 |
2 | |||
| test_clean_path | |
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 | use phpbb\filesystem\helper as filesystem_helper; |
| 15 | |
| 16 | class phpbb_filesystem_helper_clean_path_test extends phpbb_test_case |
| 17 | { |
| 18 | |
| 19 | protected function setUp(): void |
| 20 | { |
| 21 | parent::setUp(); |
| 22 | } |
| 23 | |
| 24 | public static function clean_path_data() |
| 25 | { |
| 26 | yield ['foo', 'foo']; |
| 27 | yield ['foo/bar', 'foo/bar']; |
| 28 | yield ['foo/bar/', 'foo/bar/']; |
| 29 | yield ['foo/./bar', 'foo/bar']; |
| 30 | yield ['foo/./././bar', 'foo/bar']; |
| 31 | yield ['foo/bar/.', 'foo/bar']; |
| 32 | yield ['./foo/bar', './foo/bar']; |
| 33 | yield ['../foo/bar', '../foo/bar']; |
| 34 | yield ['./../foo/bar', './../foo/bar']; |
| 35 | yield ['././../foo/bar', './../foo/bar']; |
| 36 | yield ['one/two/three', 'one/two/three']; |
| 37 | yield ['one/two/../three', 'one/three']; |
| 38 | yield ['one/../two/three', 'two/three']; |
| 39 | yield ['one/two/..', 'one']; |
| 40 | yield ['one/two/../', 'one/']; |
| 41 | yield ['one/two/../three/../four', 'one/four']; |
| 42 | yield ['one/two/three/../../four', 'one/four']; |
| 43 | } |
| 44 | |
| 45 | /** |
| 46 | * @dataProvider clean_path_data |
| 47 | */ |
| 48 | public function test_clean_path($input, $expected) |
| 49 | { |
| 50 | $this->assertEquals($expected, filesystem_helper::clean_path($input)); |
| 51 | } |
| 52 | } |