diff options
author | Luke Shumaker <lukeshu@sbcglobal.net> | 2016-05-01 15:30:02 -0400 |
---|---|---|
committer | Luke Shumaker <lukeshu@sbcglobal.net> | 2016-05-01 15:30:02 -0400 |
commit | 1de335ad3f395ca6861085393ba366a9e3fb4a0d (patch) | |
tree | f1fdd326034e05177596851be6a7127615d81498 /tests/phpunit/includes/TemplateParserTest.php | |
parent | 9c75fa8ff6d4d38ef552c00fef5969fb154765e8 (diff) | |
parent | f6d65e533c62f6deb21342d4901ece24497b433e (diff) |
Merge commit 'f6d65'
# Conflicts:
# skins/ArchLinux/ArchLinux.php
Diffstat (limited to 'tests/phpunit/includes/TemplateParserTest.php')
-rw-r--r-- | tests/phpunit/includes/TemplateParserTest.php | 63 |
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', + ) + ); + } +} |