Skip to content

Commit

Permalink
MDL-69553 output: Unit tests for loading multiline string defines
Browse files Browse the repository at this point in the history
  • Loading branch information
NeillM committed Oct 21, 2020
1 parent 3ba1073 commit b65c22d
Showing 1 changed file with 82 additions and 1 deletion.
83 changes: 82 additions & 1 deletion lib/tests/mustache_template_source_loader_test.php
Expand Up @@ -357,12 +357,43 @@ public function test_scan_template_source_for_dependencies_test_cases() {
$bar = '{{! a comment }}{{> core/baz }}';
$baz = '{{! a comment }}{{#str}} hide, core {{/str}}';
$bop = '{{! a comment }}hello';
$multiline1 = <<<TEMPLATE
{{! a comment }}{{#str}} authorreplyingprivatelytoauthor,
mod_forum {{/str}}
TEMPLATE;
$multiline2 = <<<TEMPLATE
{{! a comment }}{{#str}}
authorreplyingprivatelytoauthor,
mod_forum {{/str}}
TEMPLATE;
$multiline3 = <<<TEMPLATE
{{! a comment }}{{#str}}
authorreplyingprivatelytoauthor,
mod_forum
{{/str}}
TEMPLATE;
$multiline4 = <<<TEMPLATE
{{! a comment }}{{#str}}
authorreplyingprivatelytoauthor, mod_forum
{{/str}}
TEMPLATE;
$multiline5 = <<<TEMPLATE
{{! a comment }}{{#str}}
hide
{{/str}}
TEMPLATE;

$cache = [
'core' => [
'foo' => $foo,
'bar' => $bar,
'baz' => $baz,
'bop' => $bop
'bop' => $bop,
'multiline1' => $multiline1,
'multiline2' => $multiline2,
'multiline3' => $multiline3,
'multiline4' => $multiline4,
'multiline5' => $multiline5,
]
];
$loader = $this->build_loader_from_static_cache($cache);
Expand Down Expand Up @@ -409,6 +440,56 @@ public function test_scan_template_source_for_dependencies_test_cases() {
]
]
],
'string: component on new line' => [
'loader' => $loader,
'source' => $multiline1,
'expected' => [
'templates' => [],
'strings' => [
'mod_forum' => ['authorreplyingprivatelytoauthor']
]
]
],
'string: identifier on own line' => [
'loader' => $loader,
'source' => $multiline2,
'expected' => [
'templates' => [],
'strings' => [
'mod_forum' => ['authorreplyingprivatelytoauthor']
]
]
],
'string: all parts on new lines' => [
'loader' => $loader,
'source' => $multiline3,
'expected' => [
'templates' => [],
'strings' => [
'mod_forum' => ['authorreplyingprivatelytoauthor']
]
]
],
'string: id and component on own line' => [
'loader' => $loader,
'source' => $multiline4,
'expected' => [
'templates' => [],
'strings' => [
'mod_forum' => ['authorreplyingprivatelytoauthor']
]
]
],
'string: no component' => [
'loader' => $loader,
'source' => $multiline5,
'expected' => [
'templates' => [],
'strings' => [
'core' => ['hide']
]
]
],
];
}

Expand Down

0 comments on commit b65c22d

Please sign in to comment.