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_is_absolute_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
 is_absolute_data
0.00% covered (danger)
0.00%
0 / 19
0.00% covered (danger)
0.00%
0 / 1
2
 test_is_absolute
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_is_absolute_test extends phpbb_test_case
15{
16    /** @var \phpbb\filesystem\filesystem_interface */
17    protected $filesystem;
18
19    protected function setUp(): void
20    {
21        parent::setUp();
22
23        $this->filesystem = new \phpbb\filesystem\filesystem();
24    }
25
26    public static function is_absolute_data()
27    {
28        return array(
29            // Empty
30            array('', false),
31
32            // Absolute unix style
33            array('/etc/phpbb', true),
34            // Unix does not support \ so that is not an absolute path
35            array('\etc\phpbb', false),
36
37            // Absolute windows style
38            array('c:\windows', true),
39            array('C:\Windows', true),
40            array('c:/windows', true),
41            array('C:/Windows', true),
42
43            // Executable
44            array('etc/phpbb', false),
45            array('explorer.exe', false),
46
47            // Relative subdir
48            array('Windows\System32', false),
49            array('Windows\System32\explorer.exe', false),
50            array('Windows/System32', false),
51            array('Windows/System32/explorer.exe', false),
52
53            // Relative updir
54            array('..\Windows\System32', false),
55            array('..\Windows\System32\explorer.exe', false),
56            array('../Windows/System32', false),
57            array('../Windows/System32/explorer.exe', false),
58        );
59    }
60
61    /**
62     * @dataProvider is_absolute_data
63     */
64    public function test_is_absolute($path, $expected)
65    {
66        $this->assertEquals($expected, $this->filesystem->is_absolute_path($path));
67    }
68}