3 class InstallDocFormatterTest
extends MediaWikiTestCase
{
5 * @covers InstallDocFormatter
6 * @dataProvider provideDocFormattingTests
8 public function testFormat( $expected, $unformattedText, $message = '' ) {
11 InstallDocFormatter
::format( $unformattedText ),
17 * Provider for testFormat()
19 public static function provideDocFormattingTests() {
20 # Format: (expected string, unformattedText string, optional message)
22 # Escape some wikitext
23 [ 'Install <tag>', 'Install <tag>', 'Escaping <' ],
24 [ 'Install {{template}}', 'Install {{template}}', 'Escaping [[' ],
25 [ 'Install [[page]]', 'Install [[page]]', 'Escaping {{' ],
26 [ 'Install __TOC__', 'Install __TOC__', 'Escaping __' ],
27 [ 'Install ', "Install \r", 'Removing \r' ],
29 # Transform \t{1,2} into :{1,2}
30 [ ':One indentation', "\tOne indentation", 'Replacing a single \t' ],
31 [ '::Two indentations', "\t\tTwo indentations", 'Replacing 2 x \t' ],
33 # Transform 'T123' links
35 '<span class="config-plainlink">[https://phabricator.wikimedia.org/T123 T123]</span>',
36 'T123', 'Testing T123 links' ],
38 'bug <span class="config-plainlink">[https://phabricator.wikimedia.org/T123 T123]</span>',
39 'bug T123', 'Testing bug T123 links' ],
41 '(<span class="config-plainlink">[https://phabricator.wikimedia.org/T987654 T987654]</span>)',
42 '(T987654)', 'Testing (T987654) links' ],
44 # "Tabc" shouldn't work
45 [ 'Tfoobar', 'Tfoobar', "Don't match T followed by non-digits" ],
46 [ 'T!!fakefake!!', 'T!!fakefake!!', "Don't match T followed by non-digits" ],
48 # Transform 'bug 123' links
50 '<span class="config-plainlink">[https://bugzilla.wikimedia.org/123 bug 123]</span>',
51 'bug 123', 'Testing bug 123 links' ],
53 '(<span class="config-plainlink">[https://bugzilla.wikimedia.org/987654 bug 987654]</span>)',
54 '(bug 987654)', 'Testing (bug 987654) links' ],
56 # "bug abc" shouldn't work
57 [ 'bug foobar', 'bug foobar', "Don't match bug followed by non-digits" ],
58 [ 'bug !!fakefake!!', 'bug !!fakefake!!', "Don't match bug followed by non-digits" ],
60 # Transform '$wgFooBar' links
62 '<span class="config-plainlink">'
63 . '[https://www.mediawiki.org/wiki/Manual:$wgFooBar $wgFooBar]</span>',
64 '$wgFooBar', 'Testing basic $wgFooBar' ],
66 '<span class="config-plainlink">'
67 . '[https://www.mediawiki.org/wiki/Manual:$wgFooBar45 $wgFooBar45]</span>',
68 '$wgFooBar45', 'Testing $wgFooBar45 (with numbers)' ],
70 '<span class="config-plainlink">'
71 . '[https://www.mediawiki.org/wiki/Manual:$wgFoo_Bar $wgFoo_Bar]</span>',
72 '$wgFoo_Bar', 'Testing $wgFoo_Bar (with underscore)' ],
74 # Icky variables that shouldn't link
78 'Testing $myAwesomeVariable (not starting with $wg)'
80 [ '$()not!a&Var', '$()not!a&Var', 'Testing $()not!a&Var (obviously not a variable)' ],