wiki.techinc.nl/tests/phpunit/includes/TemplateParserTest.php
Timo Tijhof 3b35719e74 tests: Remove unused $wgMemc resets
If we really need this we can do it in MediaWikiTestCase, next
to the setting of wgMainCacheType. But from what I can see the
code being tested here already doesn't use the old $wgMemc.

Change-Id: I9e4b2109b2f3c18d8d5551bbadae5711c1d4c0a6
2015-12-06 18:06:08 +00:00

75 lines
1.3 KiB
PHP

<?php
/**
* @group Templates
*/
class TemplateParserTest extends MediaWikiTestCase {
protected $templateDir;
protected function setUp() {
parent::setUp();
$this->setMwGlobals( array(
'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 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',
),
array(
'has_partial',
array(
'planet' => 'world',
),
"Partial hello world!\n in here\n",
),
array(
'bad_partial',
array(),
false,
'Exception',
),
);
}
}