aboutsummaryrefslogtreecommitdiffstats
path: root/tests/template/template_includejs_test.php
blob: 0061163eeb5d87e21bea052a543732b28985899f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
<?php
/**
*
* @package testing
* @copyright (c) 2011 phpBB Group
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
*
*/

require_once dirname(__FILE__) . '/template_test_case_with_tree.php';

class phpbb_template_template_includejs_test extends phpbb_template_template_test_case_with_tree
{
	public function test_includejs_compilation()
	{
		// Reset the engine state
		$this->setup_engine(array('assets_version' => 1));

		// Prepare correct result
		$scripts = array(
			'<script src="' . $this->test_path . '/templates/parent_and_child.js?assets_version=1"></script>',
			'<script src="' . $this->test_path . '/templates/parent_and_child.js?assets_version=0"></script>',
			'<script src="' . $this->test_path . '/templates/parent_and_child.js?test=1&assets_version=0"></script>',
			'<script src="' . $this->test_path . '/templates/parent_and_child.js?test=1&amp;assets_version=0"></script>',
			'<script src="' . $this->test_path . '/templates/parent_and_child.js?test=1;assets_version=0"></script>',
			'<script src="' . $this->test_path . '/parent_templates/parent_only.js?assets_version=1"></script>',
			'<script src="' . $this->test_path . '/templates/child_only.js?assets_version=1"></script>',
			'<script src="' . $this->test_path . '/templates/subdir/parent_only.js?assets_version=1"></script>',
			'<script src="' . $this->test_path . '/templates/subdir/subsubdir/parent_only.js?assets_version=1"></script>',
			'<script src="' . $this->test_path . '/templates/subdir/parent_only.js?assets_version=1"></script>',
			'<script src="' . $this->test_path . '/templates/child_only.js?test1=1&amp;test2=2&amp;assets_version=1#test3"></script>',
			'<script src="' . $this->test_path . '/parent_templates/parent_only.js?test1=1&amp;test2=2&amp;assets_version=1#test3"></script>',
			'<script src="' . $this->test_path . '/parent_templates/parent_only.js?test1=1;test2=2;assets_version=1#test3"></script>',
			'<script src="' . $this->test_path . '/parent_templates/parent_only.js?test1=&quot;&amp;assets_version=1#test3"></script>',
			'<script src="//phpbb.com/b.js"></script>',
			'<script src="http://phpbb.com/b.js?c=d#f"></script>',
			'<script src="http://phpbb.com/b.js?c=d&assets_version=1#f"></script>',
			'<script src="//[1234:d123:a105::123]/test.js"></script>',
		);

		// Run test
		$this->run_template('includejs.html', array('PARENT' => 'parent_only.js', 'SUBDIR' => 'subdir', 'EXT' => 'js'), array(), array(), implode('', $scripts));
	}
}