Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
52.94% covered (warning)
52.94%
9 / 17
50.00% covered (danger)
50.00%
1 / 2
CRAP
0.00% covered (danger)
0.00%
0 / 1
phpbb_template_asset_test
52.94% covered (warning)
52.94%
9 / 17
50.00% covered (danger)
50.00%
1 / 2
2.42
0.00% covered (danger)
0.00%
0 / 1
 set_path_data
0.00% covered (danger)
0.00%
0 / 8
0.00% covered (danger)
0.00%
0 / 1
2
 test_set_path
100.00% covered (success)
100.00%
9 / 9
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\template\asset;
15
16class phpbb_template_asset_test extends phpbb_test_case
17{
18    public static function set_path_data()
19    {
20        return array(
21            // array(phpbb_root_path, given path, expected path),
22            array('.', 'foo/bar', 'foo/bar'),
23            array('../', 'foo/bar', 'foo/bar'),
24            array('./phpBB/', 'foo/bar', 'foo/bar'),
25            array('../', __DIR__ . '/foo/bar', '../' . basename(dirname(dirname(__DIR__))) . '/tests/template/foo/bar'),
26            array('./', __DIR__ . '/foo/bar', './tests/template/foo/bar'),
27            array('./phpBB/', __DIR__ . '/foo/bar', 'tests/template/foo/bar'),
28        );
29    }
30
31    /**
32     * @dataProvider set_path_data
33     */
34    public function test_set_path($phpbb_root_path, $path, $expected)
35    {
36        $path_helper = $this->getMockBuilder('\phpbb\path_helper')
37            ->disableOriginalConstructor()
38            ->onlyMethods(['get_phpbb_root_path'])
39            ->getMock();
40
41        $path_helper->method('get_phpbb_root_path')
42            ->willReturn($phpbb_root_path);
43
44        $asset = new asset('', $path_helper);
45
46        $asset->set_path($path, true);
47        $this->assertEquals($expected, $asset->get_path());
48    }
49}