Merge "(bug 45017) Check whether this request is a POST before allowing a query modul...
[lhc/web/wiklou.git] / tests / phpunit / includes / installer / InstallDocFormatterTest.php
1 <?php
2 /*
3 * To change this template, choose Tools | Templates
4 * and open the template in the editor.
5 */
6
7 class InstallDocFormatterTest extends MediaWikiTestCase {
8 /**
9 * @covers InstallDocFormatter::format
10 * @dataProvider provideDocFormattingTests
11 */
12 function testFormat( $expected, $unformattedText, $message = '' ) {
13 $this->assertEquals(
14 $expected,
15 InstallDocFormatter::format( $unformattedText ),
16 $message
17 );
18 }
19
20 /**
21 * Provider for testFormat()
22 */
23 function provideDocFormattingTests() {
24 # Format: (expected string, unformattedText string, optional message)
25 return array(
26 # Escape some wikitext
27 array( 'Install &lt;tag>', 'Install <tag>', 'Escaping <' ),
28 array( 'Install &#123;&#123;template}}', 'Install {{template}}', 'Escaping [[' ),
29 array( 'Install &#91;&#91;page]]', 'Install [[page]]', 'Escaping {{' ),
30 array( 'Install ', "Install \r", 'Removing \r' ),
31
32 # Transform \t{1,2} into :{1,2}
33 array( ':One indentation', "\tOne indentation", 'Replacing a single \t' ),
34 array( '::Two indentations', "\t\tTwo indentations", 'Replacing 2 x \t' ),
35
36 # Transform 'bug 123' links
37 array(
38 '<span class="config-plainlink">[https://bugzilla.wikimedia.org/123 bug 123]</span>',
39 'bug 123', 'Testing bug 123 links' ),
40 array(
41 '(<span class="config-plainlink">[https://bugzilla.wikimedia.org/987654 bug 987654]</span>)',
42 '(bug 987654)', 'Testing (bug 987654) links' ),
43
44 # "bug abc" shouldn't work
45 array( 'bug foobar', 'bug foobar', "Don't match bug followed by non-digits" ),
46 array( 'bug !!fakefake!!', 'bug !!fakefake!!', "Don't match bug followed by non-digits" ),
47
48 # Transform '$wgFooBar' links
49 array(
50 '<span class="config-plainlink">[http://www.mediawiki.org/wiki/Manual:$wgFooBar $wgFooBar]</span>',
51 '$wgFooBar', 'Testing basic $wgFooBar' ),
52 array(
53 '<span class="config-plainlink">[http://www.mediawiki.org/wiki/Manual:$wgFooBar45 $wgFooBar45]</span>',
54 '$wgFooBar45', 'Testing $wgFooBar45 (with numbers)' ),
55 array(
56 '<span class="config-plainlink">[http://www.mediawiki.org/wiki/Manual:$wgFoo_Bar $wgFoo_Bar]</span>',
57 '$wgFoo_Bar', 'Testing $wgFoo_Bar (with underscore)' ),
58
59 # Icky variables that shouldn't link
60 array( '$myAwesomeVariable', '$myAwesomeVariable', 'Testing $myAwesomeVariable (not starting with $wg)' ),
61 array( '$()not!a&Var', '$()not!a&Var', 'Testing $()not!a&Var (obviously not a variable)' ),
62 );
63 }
64 }