1
0
mirror of https://github.com/phpbb/phpbb.git synced 2025-02-11 19:24:10 +01:00

[ticket/13508] Add tests for include_js() and include_css() twig tokens

PHPBB3-13508
This commit is contained in:
Marc Alexander 2021-10-07 21:20:09 +02:00
parent 02e5a7afc4
commit 97034e0776
No known key found for this signature in database
GPG Key ID: 50E0D2423696F995
4 changed files with 72 additions and 44 deletions

View File

@ -125,4 +125,18 @@ class phpbb_template_template_includecss_test extends phpbb_template_template_te
// Run test
$this->run_template('includecss.html', array(), array(), array(), $expected);
}
/**
* @dataProvider template_data
*/
public function test_include_css_compilation($vars, $expected)
{
// Reset the engine state
$this->setup_engine(array('assets_version' => 1));
$this->template->assign_vars($vars);
// Run test
$this->run_template('include_css.html', array(), array(), array(), $expected);
}
}

View File

@ -106,4 +106,18 @@ class phpbb_template_template_includejs_test extends phpbb_template_template_tes
// Run test
$this->run_template('includejs.html', array_merge(array('PARENT' => 'parent_only.js', 'SUBDIR' => 'subdir', 'EXT' => 'js'), $vars), array(), array(), $expected);
}
/**
* @dataProvider template_data
*/
public function test_include_js_compilation($vars, $expected)
{
// Reset the engine state
$this->setup_engine(array('assets_version' => 1));
$this->template->assign_vars($vars);
// Run test
$this->run_template('include_js.html', array_merge(array('PARENT' => 'parent_only.js', 'SUBDIR' => 'subdir', 'EXT' => 'js'), $vars), array(), array(), $expected);
}
}

View File

@ -1,10 +1,10 @@
<!-- IF TEST === 1 -->
<!-- INCLUDECSS child_only.css -->
<!-- ELSEIF TEST === 2 -->
<!-- INCLUDECSS parent_only.css -->
<!-- ELSEIF TEST === 3 -->
<!-- INCLUDECSS @include_css/test.css -->
<!-- ELSEIF TEST === 4 -->
<!-- INCLUDECSS @include_css/child_only.css -->
<!-- ENDIF -->
{% if TEST === 1 %}
{% include_css('child_only.css') %}
{% elseif TEST === 2 %}
{% include_css('parent_only.css') %}
{% elseif TEST === 3 %}
{% include_css('@include_css/test.css') %}
{% elseif TEST === 4 %}
{% include_css('@include_css/child_only.css') %}
{% endif %}
{$STYLESHEETS}

View File

@ -1,36 +1,36 @@
<!-- IF TEST === 1 -->
<!-- INCLUDEJS parent_and_child.js -->
<!-- ELSEIF TEST === 2 -->
<!-- INCLUDEJS parent_and_child.js?assets_version=0 -->
<!-- ELSEIF TEST === 3 -->
<!-- INCLUDEJS parent_and_child.js?test=1&assets_version=0 -->
<!-- ELSEIF TEST === 4 -->
<!-- INCLUDEJS parent_and_child.js?test=1&amp;assets_version=0 -->
<!-- ELSEIF TEST === 6 -->
<!-- INCLUDEJS {PARENT} -->
<!-- ELSEIF TEST === 7 -->
<!-- DEFINE $TEST = 'child_only.js' -->
<!-- INCLUDEJS {$TEST} -->
<!-- ELSEIF TEST === 8 -->
<!-- INCLUDEJS subdir/{PARENT} -->
<!-- ELSEIF TEST === 9 -->
<!-- INCLUDEJS {SUBDIR}/subsubdir/{PARENT} -->
<!-- ELSEIF TEST === 10 -->
<!-- INCLUDEJS {SUBDIR}/parent_only.{EXT} -->
<!-- ELSEIF TEST === 11 -->
<!-- DEFINE $TEST = 'child_only.js?test1=1&amp;test2=2#test3' -->
<!-- INCLUDEJS {$TEST} -->
<!-- ELSEIF TEST === 12 -->
<!-- INCLUDEJS parent_only.js?test1=1&amp;test2=2#test3 -->
<!-- ELSEIF TEST === 14 -->
<!-- INCLUDEJS parent_only.js?test1=&quot;#test3 -->
<!-- ELSEIF TEST === 15 -->
<!-- INCLUDEJS http://phpbb.com/b.js?c=d#f -->
<!-- ELSEIF TEST === 16 -->
<!-- INCLUDEJS http://phpbb.com/b.js?c=d&assets_version=2#f -->
<!-- ELSEIF TEST === 17 -->
<!-- INCLUDEJS //phpbb.com/b.js -->
<!-- ELSEIF TEST === 18 -->
<!-- INCLUDEJS parent_and_child.js?test=1&test2=0 -->
<!-- ENDIF -->
{% if TEST === 1 %}
{% include_js('parent_and_child.js') %}
{% elseif TEST === 2 %}
{% include_js('parent_and_child.js?assets_version=0') %}
{% elseif TEST === 3 %}
{% include_js('parent_and_child.js?test=1&assets_version=0') %}
{% elseif TEST === 4 %}
{% include_js('parent_and_child.js?test=1&amp;assets_version=0') %}
{% elseif TEST === 6 %}
{% include_js(PARENT) %}
{% elseif TEST === 7 %}
{% set test_var = 'child_only.js' %}
{% include_js(test_var) %}
{% elseif TEST === 8 %}
{% include_js('subdir/' ~ PARENT) %}
{% elseif TEST === 9 %}
{% include_js(SUBDIR ~ '/subsubdir/' ~ PARENT) %}
{% elseif TEST === 10 %}
{% include_js(SUBDIR ~ '/parent_only.' ~ EXT) %}
{% elseif TEST === 11 %}
{% set test_var = 'child_only.js?test1=1&amp;test2=2#test3' %}
{% include_js(test_var) %}
{% elseif TEST === 12 %}
{% include_js('parent_only.js?test1=1&amp;test2=2#test3') %}
{% elseif TEST === 14 %}
{% include_js('parent_only.js?test1=&quot;#test3') %}
{% elseif TEST === 15 %}
{% include_js('http://phpbb.com/b.js?c=d#f') %}
{% elseif TEST === 16 %}
{% include_js('http://phpbb.com/b.js?c=d&assets_version=2#f') %}
{% elseif TEST === 17 %}
{% include_js('//phpbb.com/b.js') %}
{% elseif TEST === 18 %}
{% include_js('parent_and_child.js?test=1&test2=0') %}
{% endif %}
{$SCRIPTS}