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