r91040 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r91039‎ | r91040 | r91041 >
Date:01:26, 29 June 2011
Author:demon
Status:ok
Tags:
Comment:
Basic first round of testing for the InstallDocFormatter
Modified paths:
  • /trunk/phase3/tests/phpunit/includes/installer (added) (history)
  • /trunk/phase3/tests/phpunit/includes/installer/InstallDocFormatterTest.php (added) (history)

Diff [purge]

Index: trunk/phase3/tests/phpunit/includes/installer/InstallDocFormatterTest.php
@@ -0,0 +1,64 @@
 2+<?php
 3+/*
 4+ * To change this template, choose Tools | Templates
 5+ * and open the template in the editor.
 6+ */
 7+
 8+class InstallDocFormatterTest extends MediaWikiTestCase {
 9+ /**
 10+ * @covers InstallDocFormatter::format
 11+ * @dataProvider provideDocFormattingTests
 12+ */
 13+ function testFormat( $expected, $unformattedText, $message = '' ) {
 14+ $this->assertEquals(
 15+ $expected,
 16+ InstallDocFormatter::format( $unformattedText ),
 17+ $message
 18+ );
 19+ }
 20+
 21+ /**
 22+ * Provider for testFormat()
 23+ */
 24+ function provideDocFormattingTests() {
 25+ # Format: (expected string, unformattedText string, optional message)
 26+ return array(
 27+ # Escape some wikitext
 28+ array( 'Install &lt;tag>' , 'Install <tag>', 'Escaping <' ),
 29+ array( 'Install &#123;&#123;template}}' , 'Install {{template}}', 'Escaping [[' ),
 30+ array( 'Install &#91;&#91;page]]' , 'Install [[page]]', 'Escaping {{' ),
 31+ array( 'Install ' , "Install \r", 'Removing \r' ),
 32+
 33+ # Transform \t{1,2} into :{1,2}
 34+ array( ':One indentation', "\tOne indentation", 'Replacing a single \t' ),
 35+ array( '::Two indentations', "\t\tTwo indentations", 'Replacing 2 x \t' ),
 36+
 37+ # Transform 'bug 123' links
 38+ array(
 39+ '<span class="config-plainlink">[https://bugzilla.wikimedia.org/123 bug 123]</span>',
 40+ 'bug 123', 'Testing bug 123 links' ),
 41+ array(
 42+ '(<span class="config-plainlink">[https://bugzilla.wikimedia.org/987654 bug 987654]</span>)',
 43+ '(bug 987654)', 'Testing (bug 987654) links' ),
 44+
 45+ # "bug abc" shouldn't work
 46+ array( 'bug foobar', 'bug foobar', "Don't match bug followed by non-digits" ),
 47+ array( 'bug !!fakefake!!', 'bug !!fakefake!!', "Don't match bug followed by non-digits" ),
 48+
 49+ # Transform '$wgFooBar' links
 50+ array(
 51+ '<span class="config-plainlink">[http://www.mediawiki.org/wiki/Manual:$wgFooBar $wgFooBar]</span>',
 52+ '$wgFooBar', 'Testing basic $wgFooBar' ),
 53+ array(
 54+ '<span class="config-plainlink">[http://www.mediawiki.org/wiki/Manual:$wgFooBar45 $wgFooBar45]</span>',
 55+ '$wgFooBar45', 'Testing $wgFooBar45 (with numbers)' ),
 56+ array(
 57+ '<span class="config-plainlink">[http://www.mediawiki.org/wiki/Manual:$wgFoo_Bar $wgFoo_Bar]</span>',
 58+ '$wgFoo_Bar', 'Testing $wgFoo_Bar (with underscore)' ),
 59+
 60+ # Icky variables that shouldn't link
 61+ array( '$myAwesomeVariable', '$myAwesomeVariable', 'Testing $myAwesomeVariable (not starting with $wg)' ),
 62+ array( '$()not!a&Var', '$()not!a&Var', 'Testing $()not!a&Var (obviously not a variable)' ),
 63+ );
 64+ }
 65+}
Property changes on: trunk/phase3/tests/phpunit/includes/installer/InstallDocFormatterTest.php
___________________________________________________________________
Added: svn:eol-style
166 + native

Status & tagging log