summaryrefslogtreecommitdiff
path: root/tests/phpunit/includes/TemplateParserTest.php
diff options
context:
space:
mode:
authorPierre Schmitz <pierre@archlinux.de>2015-06-04 07:31:04 +0200
committerPierre Schmitz <pierre@archlinux.de>2015-06-04 07:58:39 +0200
commitf6d65e533c62f6deb21342d4901ece24497b433e (patch)
treef28adf0362d14bcd448f7b65a7aaf38650f923aa /tests/phpunit/includes/TemplateParserTest.php
parentc27b2e832fe25651ef2410fae85b41072aae7519 (diff)
Update to MediaWiki 1.25.1
Diffstat (limited to 'tests/phpunit/includes/TemplateParserTest.php')
-rw-r--r--tests/phpunit/includes/TemplateParserTest.php63
1 files changed, 63 insertions, 0 deletions
diff --git a/tests/phpunit/includes/TemplateParserTest.php b/tests/phpunit/includes/TemplateParserTest.php
new file mode 100644
index 00000000..81854ff3
--- /dev/null
+++ b/tests/phpunit/includes/TemplateParserTest.php
@@ -0,0 +1,63 @@
+<?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',
+ )
+ );
+ }
+}