MediaWiki  REL1_19
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         function testFormat( $expected, $unformattedText, $message = '' ) {
00013                 $this->assertEquals(
00014                         $expected,
00015                         InstallDocFormatter::format( $unformattedText ),
00016                         $message
00017                 );
00018         }
00019 
00023         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 ' , "Install \r", 'Removing \r' ),
00031 
00032                         # Transform \t{1,2} into :{1,2}
00033                         array( ':One indentation', "\tOne indentation", 'Replacing a single \t' ),
00034                         array( '::Two indentations', "\t\tTwo indentations", 'Replacing 2 x \t' ),
00035 
00036                         # Transform 'bug 123' links
00037                         array( 
00038                                 '<span class="config-plainlink">[https://bugzilla.wikimedia.org/123 bug 123]</span>',
00039                                 'bug 123', 'Testing bug 123 links' ),
00040                         array(
00041                                 '(<span class="config-plainlink">[https://bugzilla.wikimedia.org/987654 bug 987654]</span>)',
00042                                 '(bug 987654)', 'Testing (bug 987654) links' ),
00043 
00044                         # "bug abc" shouldn't work
00045                         array( 'bug foobar', 'bug foobar', "Don't match bug followed by non-digits" ),
00046                         array( 'bug !!fakefake!!', 'bug !!fakefake!!', "Don't match bug followed by non-digits" ),
00047 
00048                         # Transform '$wgFooBar' links
00049                         array(
00050                                 '<span class="config-plainlink">[http://www.mediawiki.org/wiki/Manual:$wgFooBar $wgFooBar]</span>',
00051                                 '$wgFooBar', 'Testing basic $wgFooBar' ),
00052                         array(
00053                                 '<span class="config-plainlink">[http://www.mediawiki.org/wiki/Manual:$wgFooBar45 $wgFooBar45]</span>',
00054                                 '$wgFooBar45', 'Testing $wgFooBar45 (with numbers)' ),
00055                         array(
00056                                 '<span class="config-plainlink">[http://www.mediawiki.org/wiki/Manual:$wgFoo_Bar $wgFoo_Bar]</span>',
00057                                 '$wgFoo_Bar', 'Testing $wgFoo_Bar (with underscore)' ),
00058                         
00059                         # Icky variables that shouldn't link
00060                         array( '$myAwesomeVariable', '$myAwesomeVariable', 'Testing $myAwesomeVariable (not starting with $wg)' ),
00061                         array( '$()not!a&Var', '$()not!a&Var', 'Testing $()not!a&Var (obviously not a variable)' ),
00062                 );
00063         }
00064 }