3 * To change this template, choose Tools | Templates
4 * and open the template in the editor.
7 class InstallDocFormatterTest
extends MediaWikiTestCase
{
9 * @covers InstallDocFormatter::format
10 * @dataProvider provideDocFormattingTests
12 function testFormat( $expected, $unformattedText, $message = '' ) {
15 InstallDocFormatter
::format( $unformattedText ),
21 * Provider for testFormat()
23 public static function provideDocFormattingTests() {
24 # Format: (expected string, unformattedText string, optional message)
26 # Escape some wikitext
27 array( 'Install <tag>', 'Install <tag>', 'Escaping <' ),
28 array( 'Install {{template}}', 'Install {{template}}', 'Escaping [[' ),
29 array( 'Install [[page]]', 'Install [[page]]', 'Escaping {{' ),
30 array( 'Install ', "Install \r", 'Removing \r' ),
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' ),
36 # Transform 'bug 123' links
38 '<span class="config-plainlink">[https://bugzilla.wikimedia.org/123 bug 123]</span>',
39 'bug 123', 'Testing bug 123 links' ),
41 '(<span class="config-plainlink">[https://bugzilla.wikimedia.org/987654 bug 987654]</span>)',
42 '(bug 987654)', 'Testing (bug 987654) links' ),
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" ),
48 # Transform '$wgFooBar' links
50 '<span class="config-plainlink">[http://www.mediawiki.org/wiki/Manual:$wgFooBar $wgFooBar]</span>',
51 '$wgFooBar', 'Testing basic $wgFooBar' ),
53 '<span class="config-plainlink">[http://www.mediawiki.org/wiki/Manual:$wgFooBar45 $wgFooBar45]</span>',
54 '$wgFooBar45', 'Testing $wgFooBar45 (with numbers)' ),
56 '<span class="config-plainlink">[http://www.mediawiki.org/wiki/Manual:$wgFoo_Bar $wgFoo_Bar]</span>',
57 '$wgFoo_Bar', 'Testing $wgFoo_Bar (with underscore)' ),
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)' ),