5 * @covers TemplateParser
7 class TemplateParserTest
extends MediaWikiTestCase
{
9 protected $templateDir;
11 protected function setUp() {
14 $this->setMwGlobals( [
15 'wgSecretKey' => 'foo',
18 $this->templateDir
= dirname( __DIR__
) . '/data/templates/';
22 * @dataProvider provideProcessTemplate
24 public function testProcessTemplate( $name, $args, $result, $exception = false ) {
26 $this->setExpectedException( $exception );
28 $tp = new TemplateParser( $this->templateDir
);
29 $this->assertEquals( $result, $tp->processTemplate( $name, $args ) );
32 public static function provideProcessTemplate() {
50 'UnexpectedValueException'
56 'UnexpectedValueException'
62 'UnexpectedValueException'
65 // Allegedly this can strip ext in windows.
69 'UnexpectedValueException'
75 'UnexpectedValueException'
81 'UnexpectedValueException'
87 'UnexpectedValueException'
90 'nonexistenttemplate',
100 "Partial hello world!\n in here\n",
111 public function testEnableRecursivePartials() {
112 $tp = new TemplateParser( $this->templateDir
);
113 $data = [ 'r' => [ 'r' => [ 'r' => [] ] ] ];
115 $tp->enableRecursivePartials( true );
116 $this->assertEquals( 'rrr', $tp->processTemplate( 'recurse', $data ) );
118 $tp->enableRecursivePartials( false );
119 $this->setExpectedException( Exception
::class );
120 $tp->processTemplate( 'recurse', $data );