wiki.techinc.nl/tests/phpunit/includes/TemplateParserTest.php
Kunal Mehta 2f88829e1b TemplateParser: make most functions protected, only expose processTemplate()
All of the other functions expose internal implementation details, which no
external caller should ever need. In fact, no external caller does use these
functions directly.

The TemplateParser::compile() tests were removed as they're simply just
checking LightnCandy functionality, which is something the library should be
doing.

Change-Id: If9003d40315e0e5aa361c174b764b799e3b88c34
2015-03-22 20:31:59 -07:00

63 lines
1.2 KiB
PHP

<?php
/**
* @group Templates
*/
class TemplateParserTest extends MediaWikiTestCase {
protected $templateDir;
protected function setUp() {
parent::setUp();
$this->setMwGlobals( array(
'wgSecretKey' => 'foo',
'wgMemc' => new EmptyBagOStuff(),
) );
$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 array(
array(
'foobar',
array(),
"hello world!\n"
),
array(
'foobar_args',
array(
'planet' => 'world',
),
"hello world!\n",
),
array(
'../foobar',
array(),
false,
'UnexpectedValueException'
),
array(
'nonexistenttemplate',
array(),
false,
'RuntimeException',
)
);
}
}