wiki.techinc.nl/tests/phpunit/includes/TemplateParserTest.php
kaldari 2ec0272218 Adding TemplateParser class providing interface to Mustache templates
The TemplateParser class provides a server-side interface to cachable
dynamically-compiled Mustache templates. It currently uses the
lightncandy library to do compilation (which is already included in
the vendor repo).

Also converting NoLocalSettings.php to use it as a proof-of-concept.

Bug: T379
Change-Id: I28cd13d4d1132bd386e2ae2f4f0d1dd88ad9162b
2015-02-19 17:41:45 -08:00

30 lines
736 B
PHP

<?php
/**
* @group Templates
*/
class TemplateParserTest extends MediaWikiTestCase {
/**
* @covers TemplateParser::compile
*/
public function testTemplateCompilation() {
$this->assertRegExp(
'/^<\?php return function/',
TemplateParser::compile( "test" ),
'compile a simple mustache template'
);
}
/**
* @covers TemplateParser::compile
*/
public function testTemplateCompilationWithVariable() {
$this->assertRegExp(
'/return \'\'\.htmlentities\(\(string\)\(\(isset\(\$in\[\'value\'\]\) && '
. 'is_array\(\$in\)\) \? \$in\[\'value\'\] : null\), ENT_QUOTES, '
. '\'UTF-8\'\)\.\'\';/',
TemplateParser::compile( "{{value}}" ),
'compile a mustache template with an escaped variable'
);
}
}