| 1 |
<?php |
| 2 |
|
| 3 |
use MediaWiki\Installer\InstallDocFormatter; |
| 4 |
|
| 5 |
class InstallDocFormatterTest extends MediaWikiUnitTestCase { |
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
public function testFormat( $expected, $unformattedText, $message = '' ) { |
| 11 |
$this->assertEquals( |
| 12 |
$expected, |
| 13 |
InstallDocFormatter::format( $unformattedText ), |
| 14 |
$message |
| 15 |
); |
| 16 |
} |
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
public static function provideDocFormattingTests() { |
| 22 |
|
| 23 |
return [ |
| 24 |
|
| 25 |
[ 'Install <tag>', 'Install <tag>', 'Escaping <' ], |
| 26 |
[ 'Install {{template}}', 'Install {{template}}', 'Escaping [[' ], |
| 27 |
[ 'Install [[page]]', 'Install [[page]]', 'Escaping {{' ], |
| 28 |
[ 'Install __TOC__', 'Install __TOC__', 'Escaping __' ], |
| 29 |
[ 'Install ', "Install \r", 'Removing \r' ], |
| 30 |
|
| 31 |
|
| 32 |
[ ':One indentation', "\tOne indentation", 'Replacing a single \t' ], |
| 33 |
[ '::Two indentations', "\t\tTwo indentations", 'Replacing 2 x \t' ], |
| 34 |
|
| 35 |
|
| 36 |
[ |
| 37 |
'<span class="config-plainlink">[https://phabricator.wikimedia.org/T123 T123]</span>', |
| 38 |
'T123', 'Testing T123 links' ], |
| 39 |
[ |
| 40 |
'bug <span class="config-plainlink">[https://phabricator.wikimedia.org/T123 T123]</span>', |
| 41 |
'bug T123', 'Testing bug T123 links' ], |
| 42 |
[ |
| 43 |
'(<span class="config-plainlink">[https://phabricator.wikimedia.org/T987654 T987654]</span>)', |
| 44 |
'(T987654)', 'Testing (T987654) links' ], |
| 45 |
|
| 46 |
|
| 47 |
[ 'Tfoobar', 'Tfoobar', "Don't match T followed by non-digits" ], |
| 48 |
[ 'T!!fakefake!!', 'T!!fakefake!!', "Don't match T followed by non-digits" ], |
| 49 |
|
| 50 |
|
| 51 |
[ |
| 52 |
'<span class="config-plainlink">[https://bugzilla.wikimedia.org/123 bug 123]</span>', |
| 53 |
'bug 123', 'Testing bug 123 links' ], |
| 54 |
[ |
| 55 |
'(<span class="config-plainlink">[https://bugzilla.wikimedia.org/987654 bug 987654]</span>)', |
| 56 |
'(bug 987654)', 'Testing (bug 987654) links' ], |
| 57 |
|
| 58 |
|
| 59 |
[ 'bug foobar', 'bug foobar', "Don't match bug followed by non-digits" ], |
| 60 |
[ 'bug !!fakefake!!', 'bug !!fakefake!!', "Don't match bug followed by non-digits" ], |
| 61 |
|
| 62 |
|
| 63 |
[ |
| 64 |
'<span class="config-plainlink">' |
| 65 |
. '[https://www.mediawiki.org/wiki/Manual:$wgFooBar $wgFooBar]</span>', |
| 66 |
'$wgFooBar', 'Testing basic $wgFooBar' ], |
| 67 |
[ |
| 68 |
'<span class="config-plainlink">' |
| 69 |
. '[https://www.mediawiki.org/wiki/Manual:$wgFooBar45 $wgFooBar45]</span>', |
| 70 |
'$wgFooBar45', 'Testing $wgFooBar45 (with numbers)' ], |
| 71 |
[ |
| 72 |
'<span class="config-plainlink">' |
| 73 |
. '[https://www.mediawiki.org/wiki/Manual:$wgFoo_Bar $wgFoo_Bar]</span>', |
| 74 |
'$wgFoo_Bar', 'Testing $wgFoo_Bar (with underscore)' ], |
| 75 |
|
| 76 |
|
| 77 |
[ |
| 78 |
'$myAwesomeVariable', |
| 79 |
'$myAwesomeVariable', |
| 80 |
'Testing $myAwesomeVariable (not starting with $wg)' |
| 81 |
], |
| 82 |
[ '$()not!a&Var', '$()not!a&Var', 'Testing $()not!a&Var (obviously not a variable)' ], |
| 83 |
]; |
| 84 |
} |
| 85 |
} |