Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
10.53% covered (danger)
10.53%
2 / 19
66.67% covered (warning)
66.67%
2 / 3
CRAP
0.00% covered (danger)
0.00%
0 / 1
phpbb_filesystem_helper_is_absolute_test
10.53% covered (danger)
10.53%
2 / 19
66.67% covered (warning)
66.67%
2 / 3
9.45
0.00% covered (danger)
0.00%
0 / 1
 setUp
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 is_absolute_data
0.00% covered (danger)
0.00%
0 / 17
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
14use phpbb\filesystem\helper as filesystem_helper;
15
16class phpbb_filesystem_helper_is_absolute_test extends phpbb_test_case
17{
18
19    protected function setUp(): void
20    {
21        parent::setUp();
22    }
23
24    public static function is_absolute_data()
25    {
26        // Empty
27        yield ['', false];
28
29        // Absolute unix style
30        yield ['/etc/phpbb', true];
31        // Unix does not support \ so that is not an absolute path
32        yield ['\etc\phpbb', false];
33
34        // Absolute windows style
35        yield ['c:\windows', true];
36        yield ['C:\Windows', true];
37        yield ['c:/windows', true];
38        yield ['C:/Windows', true];
39
40        // Executable
41        yield ['etc/phpbb', false];
42        yield ['explorer.exe', false];
43
44        // Relative subdir
45        yield ['Windows\System32', false];
46        yield ['Windows\System32\explorer.exe', false];
47        yield ['Windows/System32', false];
48        yield ['Windows/System32/explorer.exe', false];
49
50        // Relative updir
51        yield ['..\Windows\System32', false];
52        yield ['..\Windows\System32\explorer.exe', false];
53        yield ['../Windows/System32', false];
54        yield ['../Windows/System32/explorer.exe', false];
55    }
56
57    /**
58     * @dataProvider is_absolute_data
59     */
60    public function test_is_absolute($path, $expected)
61    {
62        $this->assertEquals($expected, filesystem_helper::is_absolute_path($path));
63    }
64}