Merge "DatabaseMssql: Don't duplicate body of makeList()"
[mediawiki.git] / tests / phpunit / includes / installer / InstallDocFormatterTest.php
blob724f0c885fcb01813c8690e31f6af6c75b57e80d
1 <?php
2 /*
3 * To change this template, choose Tools | Templates
4 * and open the template in the editor.
5 */
7 class InstallDocFormatterTest extends MediaWikiTestCase {
8 /**
9 * @covers InstallDocFormatter::format
10 * @dataProvider provideDocFormattingTests
12 public function testFormat( $expected, $unformattedText, $message = '' ) {
13 $this->assertEquals(
14 $expected,
15 InstallDocFormatter::format( $unformattedText ),
16 $message
20 /**
21 * Provider for testFormat()
23 public static 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 &#95;&#95;TOC&#95;&#95;', 'Install __TOC__', 'Escaping __' ),
31 array( 'Install ', "Install \r", 'Removing \r' ),
33 # Transform \t{1,2} into :{1,2}
34 array( ':One indentation', "\tOne indentation", 'Replacing a single \t' ),
35 array( '::Two indentations', "\t\tTwo indentations", 'Replacing 2 x \t' ),
37 # Transform 'T123' links
38 array(
39 '<span class="config-plainlink">[https://phabricator.wikimedia.org/T123 T123]</span>',
40 'T123', 'Testing T123 links' ),
41 array(
42 'bug <span class="config-plainlink">[https://phabricator.wikimedia.org/T123 T123]</span>',
43 'bug T123', 'Testing bug T123 links' ),
44 array(
45 '(<span class="config-plainlink">[https://phabricator.wikimedia.org/T987654 T987654]</span>)',
46 '(T987654)', 'Testing (T987654) links' ),
48 # "Tabc" shouldn't work
49 array( 'Tfoobar', 'Tfoobar', "Don't match T followed by non-digits" ),
50 array( 'T!!fakefake!!', 'T!!fakefake!!', "Don't match T followed by non-digits" ),
52 # Transform 'bug 123' links
53 array(
54 '<span class="config-plainlink">[https://bugzilla.wikimedia.org/123 bug 123]</span>',
55 'bug 123', 'Testing bug 123 links' ),
56 array(
57 '(<span class="config-plainlink">[https://bugzilla.wikimedia.org/987654 bug 987654]</span>)',
58 '(bug 987654)', 'Testing (bug 987654) links' ),
60 # "bug abc" shouldn't work
61 array( 'bug foobar', 'bug foobar', "Don't match bug followed by non-digits" ),
62 array( 'bug !!fakefake!!', 'bug !!fakefake!!', "Don't match bug followed by non-digits" ),
64 # Transform '$wgFooBar' links
65 array(
66 '<span class="config-plainlink">'
67 . '[https://www.mediawiki.org/wiki/Manual:$wgFooBar $wgFooBar]</span>',
68 '$wgFooBar', 'Testing basic $wgFooBar' ),
69 array(
70 '<span class="config-plainlink">'
71 . '[https://www.mediawiki.org/wiki/Manual:$wgFooBar45 $wgFooBar45]</span>',
72 '$wgFooBar45', 'Testing $wgFooBar45 (with numbers)' ),
73 array(
74 '<span class="config-plainlink">'
75 . '[https://www.mediawiki.org/wiki/Manual:$wgFoo_Bar $wgFoo_Bar]</span>',
76 '$wgFoo_Bar', 'Testing $wgFoo_Bar (with underscore)' ),
78 # Icky variables that shouldn't link
79 array(
80 '$myAwesomeVariable',
81 '$myAwesomeVariable',
82 'Testing $myAwesomeVariable (not starting with $wg)'
84 array( '$()not!a&Var', '$()not!a&Var', 'Testing $()not!a&Var (obviously not a variable)' ),