Merge "mw.Upload.BookletLayout/Dialog: Add determinate progress bar"
[lhc/web/wiklou.git] / tests / phpunit / includes / TemplateParserTest.php
1 <?php
2
3 /**
4 * @group Templates
5 */
6 class TemplateParserTest extends MediaWikiTestCase {
7
8 protected $templateDir;
9
10 protected function setUp() {
11 parent::setUp();
12
13 $this->setMwGlobals( [
14 'wgSecretKey' => 'foo',
15 ] );
16
17 $this->templateDir = dirname( __DIR__ ) . '/data/templates/';
18 }
19
20 /**
21 * @dataProvider provideProcessTemplate
22 * @covers TemplateParser::processTemplate
23 * @covers TemplateParser::getTemplate
24 * @covers TemplateParser::getTemplateFilename
25 */
26 public function testProcessTemplate( $name, $args, $result, $exception = false ) {
27 if ( $exception ) {
28 $this->setExpectedException( $exception );
29 }
30 $tp = new TemplateParser( $this->templateDir );
31 $this->assertEquals( $result, $tp->processTemplate( $name, $args ) );
32 }
33
34 public static function provideProcessTemplate() {
35 return [
36 [
37 'foobar',
38 [],
39 "hello world!\n"
40 ],
41 [
42 'foobar_args',
43 [
44 'planet' => 'world',
45 ],
46 "hello world!\n",
47 ],
48 [
49 '../foobar',
50 [],
51 false,
52 'UnexpectedValueException'
53 ],
54 [
55 'nonexistenttemplate',
56 [],
57 false,
58 'RuntimeException',
59 ],
60 [
61 'has_partial',
62 [
63 'planet' => 'world',
64 ],
65 "Partial hello world!\n in here\n",
66 ],
67 [
68 'bad_partial',
69 [],
70 false,
71 'Exception',
72 ],
73 ];
74 }
75 }