Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
8.33% |
6 / 72 |
|
66.67% |
2 / 3 |
CRAP | |
0.00% |
0 / 1 |
| phpbb_template_template_includejs_test | |
8.33% |
6 / 72 |
|
66.67% |
2 / 3 |
9.93 | |
0.00% |
0 / 1 |
| template_data | |
0.00% |
0 / 66 |
|
0.00% |
0 / 1 |
2 | |||
| test_includejs_compilation | |
100.00% |
3 / 3 |
|
100.00% |
1 / 1 |
1 | |||
| test_include_js_compilation | |
100.00% |
3 / 3 |
|
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 | require_once __DIR__ . '/template_test_case_with_tree.php'; |
| 15 | |
| 16 | class phpbb_template_template_includejs_test extends phpbb_template_template_test_case_with_tree |
| 17 | { |
| 18 | public static function template_data() |
| 19 | { |
| 20 | return array( |
| 21 | /* |
| 22 | array( |
| 23 | // vars |
| 24 | // expected |
| 25 | ), |
| 26 | */ |
| 27 | array( |
| 28 | array('TEST' => 1), |
| 29 | '<script src="tests/template/templates/parent_and_child.js?assets_version=1"></script>', |
| 30 | ), |
| 31 | array( |
| 32 | array('TEST' => 2), |
| 33 | '<script src="tests/template/templates/parent_and_child.js?assets_version=0"></script>', |
| 34 | ), |
| 35 | array( |
| 36 | array('TEST' => 3), |
| 37 | '<script src="tests/template/templates/parent_and_child.js?test=1&assets_version=0"></script>', |
| 38 | ), |
| 39 | array( |
| 40 | array('TEST' => 4), |
| 41 | '<script src="tests/template/templates/parent_and_child.js?test=1&assets_version=0"></script>', |
| 42 | ), |
| 43 | array( |
| 44 | array('TEST' => 6), |
| 45 | '<script src="tests/template/parent_templates/parent_only.js?assets_version=1"></script>', |
| 46 | ), |
| 47 | array( |
| 48 | array('TEST' => 7), |
| 49 | '<script src="tests/template/templates/child_only.js?assets_version=1"></script>', |
| 50 | ), |
| 51 | array( |
| 52 | array('TEST' => 8), |
| 53 | '<script src="tests/template/templates/subdir/parent_only.js?assets_version=1"></script>', |
| 54 | ), |
| 55 | array( |
| 56 | array('TEST' => 9), |
| 57 | '<script src="tests/template/templates/subdir/subsubdir/parent_only.js?assets_version=1"></script>', |
| 58 | ), |
| 59 | array( |
| 60 | array('TEST' => 10), |
| 61 | '<script src="tests/template/templates/subdir/parent_only.js?assets_version=1"></script>', |
| 62 | ), |
| 63 | array( |
| 64 | array('TEST' => 11), |
| 65 | '<script src="tests/template/templates/child_only.js?test1=1&test2=2&assets_version=1#test3"></script>', |
| 66 | ), |
| 67 | array( |
| 68 | array('TEST' => 12), |
| 69 | '<script src="tests/template/parent_templates/parent_only.js?test1=1&test2=2&assets_version=1#test3"></script>', |
| 70 | ), |
| 71 | array( |
| 72 | array('TEST' => 14), |
| 73 | '<script src="tests/template/parent_templates/parent_only.js?test1="&assets_version=1#test3"></script>', |
| 74 | ), |
| 75 | array( |
| 76 | array('TEST' => 15), |
| 77 | '<script src="http://phpbb.com/b.js?c=d#f"></script>', |
| 78 | ), |
| 79 | array( |
| 80 | array('TEST' => 16), |
| 81 | '<script src="http://phpbb.com/b.js?c=d&assets_version=2#f"></script>', |
| 82 | ), |
| 83 | array( |
| 84 | array('TEST' => 17), |
| 85 | '<script src="//phpbb.com/b.js"></script>', |
| 86 | ), |
| 87 | array( |
| 88 | array('TEST' => 18), |
| 89 | '<script src="tests/template/templates/parent_and_child.js?test=1&test2=0&assets_version=1"></script>', |
| 90 | ), |
| 91 | ); |
| 92 | } |
| 93 | |
| 94 | /** |
| 95 | * @dataProvider template_data |
| 96 | */ |
| 97 | public function test_includejs_compilation($vars, $expected) |
| 98 | { |
| 99 | // Reset the engine state |
| 100 | $this->setup_engine(array('assets_version' => 1)); |
| 101 | |
| 102 | $this->template->assign_vars($vars); |
| 103 | |
| 104 | // Run test |
| 105 | $this->run_template('includejs.html', array_merge(array('PARENT' => 'parent_only.js', 'SUBDIR' => 'subdir', 'EXT' => 'js'), $vars), array(), array(), $expected); |
| 106 | } |
| 107 | |
| 108 | /** |
| 109 | * @dataProvider template_data |
| 110 | */ |
| 111 | public function test_include_js_compilation($vars, $expected) |
| 112 | { |
| 113 | // Reset the engine state |
| 114 | $this->setup_engine(array('assets_version' => 1)); |
| 115 | |
| 116 | $this->template->assign_vars($vars); |
| 117 | |
| 118 | // Run test |
| 119 | $this->run_template('includejs_twig.html', array_merge(array('PARENT' => 'parent_only.js', 'SUBDIR' => 'subdir', 'EXT' => 'js'), $vars), array(), array(), $expected); |
| 120 | } |
| 121 | } |