Merge "Remove dead code about nlinks from Special:Wantedpages"
[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( array(
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 array(
36 array(
37 'foobar',
38 array(),
39 "hello world!\n"
40 ),
41 array(
42 'foobar_args',
43 array(
44 'planet' => 'world',
45 ),
46 "hello world!\n",
47 ),
48 array(
49 '../foobar',
50 array(),
51 false,
52 'UnexpectedValueException'
53 ),
54 array(
55 'nonexistenttemplate',
56 array(),
57 false,
58 'RuntimeException',
59 ),
60 array(
61 'has_partial',
62 array(
63 'planet' => 'world',
64 ),
65 "Partial hello world!\n in here\n",
66 ),
67 array(
68 'bad_partial',
69 array(),
70 false,
71 'Exception',
72 ),
73 );
74 }
75 }