wiki.techinc.nl/tests/phpunit/includes/TemplateParserTest.php
Kunal Mehta 6e9b4f0e9c Convert all array() syntax to []
Per wikitech-l consensus:
 https://lists.wikimedia.org/pipermail/wikitech-l/2016-February/084821.html

Notes:
* Disabled CallTimePassByReference due to false positives (T127163)

Change-Id: I2c8ce713ce6600a0bb7bf67537c87044c7a45c4b
2016-02-17 01:33:00 -08:00

75 lines
1.3 KiB
PHP

<?php
/**
* @group Templates
*/
class TemplateParserTest extends MediaWikiTestCase {
protected $templateDir;
protected function setUp() {
parent::setUp();
$this->setMwGlobals( [
'wgSecretKey' => 'foo',
] );
$this->templateDir = dirname( __DIR__ ) . '/data/templates/';
}
/**
* @dataProvider provideProcessTemplate
* @covers TemplateParser::processTemplate
* @covers TemplateParser::getTemplate
* @covers TemplateParser::getTemplateFilename
*/
public function testProcessTemplate( $name, $args, $result, $exception = false ) {
if ( $exception ) {
$this->setExpectedException( $exception );
}
$tp = new TemplateParser( $this->templateDir );
$this->assertEquals( $result, $tp->processTemplate( $name, $args ) );
}
public static function provideProcessTemplate() {
return [
[
'foobar',
[],
"hello world!\n"
],
[
'foobar_args',
[
'planet' => 'world',
],
"hello world!\n",
],
[
'../foobar',
[],
false,
'UnexpectedValueException'
],
[
'nonexistenttemplate',
[],
false,
'RuntimeException',
],
[
'has_partial',
[
'planet' => 'world',
],
"Partial hello world!\n in here\n",
],
[
'bad_partial',
[],
false,
'Exception',
],
];
}
}