rdbms: Rename "memCache" to "memStash" in LBFactory
[mediawiki.git] / tests / phpunit / includes / TemplateParserTest.php
blob2bd9086d60e0d9d3d5d452ca7d489c8505764496
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 "\000../foobar",
56 [],
57 false,
58 'UnexpectedValueException'
61 '/',
62 [],
63 false,
64 'UnexpectedValueException'
67 // Allegedly this can strip ext in windows.
68 'baz<',
69 [],
70 false,
71 'UnexpectedValueException'
74 '\\foo',
75 [],
76 false,
77 'UnexpectedValueException'
80 'C:\bar',
81 [],
82 false,
83 'UnexpectedValueException'
86 "foo\000bar",
87 [],
88 false,
89 'UnexpectedValueException'
92 'nonexistenttemplate',
93 [],
94 false,
95 'RuntimeException',
98 'has_partial',
100 'planet' => 'world',
102 "Partial hello world!\n in here\n",
105 'bad_partial',
107 false,
108 'Exception',