MediaWiki  REL1_22
InstallDocFormatterTest.php
Go to the documentation of this file.
00001 <?php
00002 /*
00003  * To change this template, choose Tools | Templates
00004  * and open the template in the editor.
00005  */
00006 
00007 class InstallDocFormatterTest extends MediaWikiTestCase {
00012     public function testFormat( $expected, $unformattedText, $message = '' ) {
00013         $this->assertEquals(
00014             $expected,
00015             InstallDocFormatter::format( $unformattedText ),
00016             $message
00017         );
00018     }
00019 
00023     public static function provideDocFormattingTests() {
00024         # Format: (expected string, unformattedText string, optional message)
00025         return array(
00026             # Escape some wikitext
00027             array( 'Install &lt;tag>', 'Install <tag>', 'Escaping <' ),
00028             array( 'Install &#123;&#123;template}}', 'Install {{template}}', 'Escaping [[' ),
00029             array( 'Install &#91;&#91;page]]', 'Install [[page]]', 'Escaping {{' ),
00030             array( 'Install &#95;&#95;TOC&#95;&#95;', 'Install __TOC__', 'Escaping __' ),
00031             array( 'Install ', "Install \r", 'Removing \r' ),
00032 
00033             # Transform \t{1,2} into :{1,2}
00034             array( ':One indentation', "\tOne indentation", 'Replacing a single \t' ),
00035             array( '::Two indentations', "\t\tTwo indentations", 'Replacing 2 x \t' ),
00036 
00037             # Transform 'bug 123' links
00038             array(
00039                 '<span class="config-plainlink">[https://bugzilla.wikimedia.org/123 bug 123]</span>',
00040                 'bug 123', 'Testing bug 123 links' ),
00041             array(
00042                 '(<span class="config-plainlink">[https://bugzilla.wikimedia.org/987654 bug 987654]</span>)',
00043                 '(bug 987654)', 'Testing (bug 987654) links' ),
00044 
00045             # "bug abc" shouldn't work
00046             array( 'bug foobar', 'bug foobar', "Don't match bug followed by non-digits" ),
00047             array( 'bug !!fakefake!!', 'bug !!fakefake!!', "Don't match bug followed by non-digits" ),
00048 
00049             # Transform '$wgFooBar' links
00050             array(
00051                 '<span class="config-plainlink">[http://www.mediawiki.org/wiki/Manual:$wgFooBar $wgFooBar]</span>',
00052                 '$wgFooBar', 'Testing basic $wgFooBar' ),
00053             array(
00054                 '<span class="config-plainlink">[http://www.mediawiki.org/wiki/Manual:$wgFooBar45 $wgFooBar45]</span>',
00055                 '$wgFooBar45', 'Testing $wgFooBar45 (with numbers)' ),
00056             array(
00057                 '<span class="config-plainlink">[http://www.mediawiki.org/wiki/Manual:$wgFoo_Bar $wgFoo_Bar]</span>',
00058                 '$wgFoo_Bar', 'Testing $wgFoo_Bar (with underscore)' ),
00059 
00060             # Icky variables that shouldn't link
00061             array( '$myAwesomeVariable', '$myAwesomeVariable', 'Testing $myAwesomeVariable (not starting with $wg)' ),
00062             array( '$()not!a&Var', '$()not!a&Var', 'Testing $()not!a&Var (obviously not a variable)' ),
00063         );
00064     }
00065 }