Update docs/hooks.txt for ShowSearchHitTitle
[mediawiki.git] / tests / phpunit / includes / TemplateParserTest.php
blob469f45a5d99c2374e403f91260e70475e7b0ddf0
1 <?php
3 /**
4 * @group Templates
5 */
6 class TemplateParserTest extends MediaWikiTestCase {
8 protected $templateDir;
10 protected function setUp() {
11 parent::setUp();
13 $this->setMwGlobals( [
14 'wgSecretKey' => 'foo',
15 ] );
17 $this->templateDir = dirname( __DIR__ ) . '/data/templates/';
20 /**
21 * @dataProvider provideProcessTemplate
22 * @covers TemplateParser::processTemplate
23 * @covers TemplateParser::getTemplate
24 * @covers TemplateParser::getTemplateFilename
26 public function testProcessTemplate( $name, $args, $result, $exception = false ) {
27 if ( $exception ) {
28 $this->setExpectedException( $exception );
30 $tp = new TemplateParser( $this->templateDir );
31 $this->assertEquals( $result, $tp->processTemplate( $name, $args ) );
34 public static function provideProcessTemplate() {
35 return [
37 'foobar',
38 [],
39 "hello world!\n"
42 'foobar_args',
44 'planet' => 'world',
46 "hello world!\n",
49 '../foobar',
50 [],
51 false,
52 'UnexpectedValueException'
55 'nonexistenttemplate',
56 [],
57 false,
58 'RuntimeException',
61 'has_partial',
63 'planet' => 'world',
65 "Partial hello world!\n in here\n",
68 'bad_partial',
69 [],
70 false,
71 'Exception',