Update formatting
authorSiebrand Mazeland <s.mazeland@xs4all.nl>
Fri, 15 Feb 2013 10:24:31 +0000 (11:24 +0100)
committerGerrit Code Review <gerrit@wikimedia.org>
Fri, 15 Feb 2013 12:44:42 +0000 (12:44 +0000)
6 of n.

Change-Id: I0ca3f1f72349623631ce1d7f3a4e2ed5edbdbdf4

15 files changed:
tests/phpunit/includes/normal/CleanUpTest.php
tests/phpunit/includes/objectcache/BagOStuffTest.php
tests/phpunit/includes/parser/MagicVariableTest.php
tests/phpunit/includes/parser/MediaWikiParserTest.php
tests/phpunit/includes/parser/NewParserTest.php
tests/phpunit/includes/parser/ParserMethodsTest.php
tests/phpunit/includes/parser/ParserPreloadTest.php
tests/phpunit/includes/parser/PreprocessorTest.php
tests/phpunit/includes/parser/TagHooksTest.php
tests/phpunit/includes/search/SearchEngineTest.php
tests/phpunit/includes/site/SiteListTest.php
tests/phpunit/includes/site/SiteTest.php
tests/phpunit/includes/specials/QueryAllSpecialPagesTest.php
tests/phpunit/includes/specials/SpecialRecentchangesTest.php
tests/phpunit/includes/specials/SpecialSearchTest.php

index d5ad18d..86fd95c 100644 (file)
@@ -65,19 +65,24 @@ class CleanUpTest extends MediaWikiTestCase {
         */
        function XtestAllChars() {
                $rep = UTF8_REPLACEMENT;
-               for( $i = 0x0; $i < UNICODE_MAX; $i++ ) {
+               for ( $i = 0x0; $i < UNICODE_MAX; $i++ ) {
                        $char = codepointToUtf8( $i );
                        $clean = UtfNormal::cleanUp( $char );
                        $x = sprintf( "%04X", $i );
-                       if( $i % 0x1000 == 0 ) echo "U+$x\n";
-                       if( $i == 0x0009 ||
-                           $i == 0x000a ||
-                           $i == 0x000d ||
-                           ($i > 0x001f && $i < UNICODE_SURROGATE_FIRST) ||
-                           ($i > UNICODE_SURROGATE_LAST && $i < 0xfffe ) ||
-                           ($i > 0xffff && $i <= UNICODE_MAX ) ) {
-                               if( isset( UtfNormal::$utfCanonicalComp[$char] ) || isset( UtfNormal::$utfCanonicalDecomp[$char] ) ) {
-                                   $comp = UtfNormal::NFC( $char );
+
+                       if ( $i % 0x1000 == 0 ) {
+                               echo "U+$x\n";
+                       }
+
+                       if ( $i == 0x0009 ||
+                               $i == 0x000a ||
+                               $i == 0x000d ||
+                               ( $i > 0x001f && $i < UNICODE_SURROGATE_FIRST ) ||
+                               ( $i > UNICODE_SURROGATE_LAST && $i < 0xfffe ) ||
+                               ( $i > 0xffff && $i <= UNICODE_MAX )
+                       ) {
+                               if ( isset( UtfNormal::$utfCanonicalComp[$char] ) || isset( UtfNormal::$utfCanonicalDecomp[$char] ) ) {
+                                       $comp = UtfNormal::NFC( $char );
                                        $this->assertEquals(
                                                bin2hex( $comp ),
                                                bin2hex( $clean ),
@@ -104,26 +109,32 @@ class CleanUpTest extends MediaWikiTestCase {
 
        /** @todo document */
        function doTestBytes( $head, $tail ) {
-               for( $i = 0x0; $i < 256; $i++ ) {
+               for ( $i = 0x0; $i < 256; $i++ ) {
                        $char = $head . chr( $i ) . $tail;
                        $clean = UtfNormal::cleanUp( $char );
                        $x = sprintf( "%02X", $i );
-                       if( $i == 0x0009 ||
-                           $i == 0x000a ||
-                           $i == 0x000d ||
-                           ($i > 0x001f && $i < 0x80) ) {
+
+                       if ( $i == 0x0009 ||
+                               $i == 0x000a ||
+                               $i == 0x000d ||
+                               ( $i > 0x001f && $i < 0x80 )
+                       ) {
                                $this->assertEquals(
                                        bin2hex( $char ),
                                        bin2hex( $clean ),
                                        "ASCII byte $x should be intact" );
-                               if( $char != $clean ) return;
+                               if ( $char != $clean ) {
+                                       return;
+                               }
                        } else {
                                $norm = $head . UTF8_REPLACEMENT . $tail;
                                $this->assertEquals(
                                        bin2hex( $norm ),
                                        bin2hex( $clean ),
                                        "Forbidden byte $x should be rejected" );
-                               if( $norm != $clean ) return;
+                               if ( $norm != $clean ) {
+                                       return;
+                               }
                        }
                }
        }
@@ -140,35 +151,42 @@ class CleanUpTest extends MediaWikiTestCase {
         * @todo document
         */
        function doTestDoubleBytes( $head, $tail ) {
-               for( $first = 0xc0; $first < 0x100; $first+=2 ) {
-                       for( $second = 0x80; $second < 0x100; $second+=2 ) {
+               for ( $first = 0xc0; $first < 0x100; $first += 2 ) {
+                       for ( $second = 0x80; $second < 0x100; $second += 2 ) {
                                $char = $head . chr( $first ) . chr( $second ) . $tail;
                                $clean = UtfNormal::cleanUp( $char );
                                $x = sprintf( "%02X,%02X", $first, $second );
-                               if( $first > 0xc1 &&
-                                   $first < 0xe0 &&
-                                   $second < 0xc0 ) {
-                                   $norm = UtfNormal::NFC( $char );
+                               if ( $first > 0xc1 &&
+                                       $first < 0xe0 &&
+                                       $second < 0xc0
+                               ) {
+                                       $norm = UtfNormal::NFC( $char );
                                        $this->assertEquals(
                                                bin2hex( $norm ),
                                                bin2hex( $clean ),
                                                "Pair $x should be intact" );
-                                   if( $norm != $clean ) return;
-                               } elseif( $first > 0xfd || $second > 0xbf ) {
+                                       if ( $norm != $clean ) {
+                                               return;
+                                       }
+                               } elseif ( $first > 0xfd || $second > 0xbf ) {
                                        # fe and ff are not legal head bytes -- expect two replacement chars
                                        $norm = $head . UTF8_REPLACEMENT . UTF8_REPLACEMENT . $tail;
                                        $this->assertEquals(
                                                bin2hex( $norm ),
                                                bin2hex( $clean ),
                                                "Forbidden pair $x should be rejected" );
-                                       if( $norm != $clean ) return;
+                                       if ( $norm != $clean ) {
+                                               return;
+                                       }
                                } else {
                                        $norm = $head . UTF8_REPLACEMENT . $tail;
                                        $this->assertEquals(
                                                bin2hex( $norm ),
                                                bin2hex( $clean ),
                                                "Forbidden pair $x should be rejected" );
-                                       if( $norm != $clean ) return;
+                                       if ( $norm != $clean ) {
+                                               return;
+                                       }
                                }
                        }
                }
@@ -184,24 +202,27 @@ class CleanUpTest extends MediaWikiTestCase {
 
        /** @todo document */
        function doTestTripleBytes( $head, $tail ) {
-               for( $first = 0xc0; $first < 0x100; $first+=2 ) {
-                       for( $second = 0x80; $second < 0x100; $second+=2 ) {
+               for ( $first = 0xc0; $first < 0x100; $first += 2 ) {
+                       for ( $second = 0x80; $second < 0x100; $second += 2 ) {
                                #for( $third = 0x80; $third < 0x100; $third++ ) {
-                               for( $third = 0x80; $third < 0x81; $third++ ) {
+                               for ( $third = 0x80; $third < 0x81; $third++ ) {
                                        $char = $head . chr( $first ) . chr( $second ) . chr( $third ) . $tail;
                                        $clean = UtfNormal::cleanUp( $char );
                                        $x = sprintf( "%02X,%02X,%02X", $first, $second, $third );
-                                       if( $first >= 0xe0 &&
+
+                                       if ( $first >= 0xe0 &&
                                                $first < 0xf0 &&
                                                $second < 0xc0 &&
-                                               $third < 0xc0 ) {
-                                               if( $first == 0xe0 && $second < 0xa0 ) {
+                                               $third < 0xc0
+                                       ) {
+                                               if ( $first == 0xe0 && $second < 0xa0 ) {
                                                        $this->assertEquals(
                                                                bin2hex( $head . UTF8_REPLACEMENT . $tail ),
                                                                bin2hex( $clean ),
                                                                "Overlong triplet $x should be rejected" );
-                                               } elseif( $first == 0xed &&
-                                                       ( chr( $first ) . chr( $second ) . chr( $third ))  >= UTF8_SURROGATE_FIRST ) {
+                                               } elseif ( $first == 0xed &&
+                                                       ( chr( $first ) . chr( $second ) . chr( $third ) ) >= UTF8_SURROGATE_FIRST
+                                               ) {
                                                        $this->assertEquals(
                                                                bin2hex( $head . UTF8_REPLACEMENT . $tail ),
                                                                bin2hex( $clean ),
@@ -212,27 +233,28 @@ class CleanUpTest extends MediaWikiTestCase {
                                                                bin2hex( $clean ),
                                                                "Triplet $x should be intact" );
                                                }
-                                       } elseif( $first > 0xc1 && $first < 0xe0 && $second < 0xc0 ) {
+                                       } elseif ( $first > 0xc1 && $first < 0xe0 && $second < 0xc0 ) {
                                                $this->assertEquals(
                                                        bin2hex( UtfNormal::NFC( $head . chr( $first ) . chr( $second ) ) . UTF8_REPLACEMENT . $tail ),
                                                        bin2hex( $clean ),
                                                        "Valid 2-byte $x + broken tail" );
-                                       } elseif( $second > 0xc1 && $second < 0xe0 && $third < 0xc0 ) {
+                                       } elseif ( $second > 0xc1 && $second < 0xe0 && $third < 0xc0 ) {
                                                $this->assertEquals(
                                                        bin2hex( $head . UTF8_REPLACEMENT . UtfNormal::NFC( chr( $second ) . chr( $third ) . $tail ) ),
                                                        bin2hex( $clean ),
                                                        "Broken head + valid 2-byte $x" );
-                                       } elseif( ( $first > 0xfd || $second > 0xfd ) &&
-                                                   ( ( $second > 0xbf && $third > 0xbf ) ||
-                                                     ( $second < 0xc0 && $third < 0xc0 ) ||
-                                                     ( $second > 0xfd ) ||
-                                                     ( $third > 0xfd ) ) ) {
+                                       } elseif ( ( $first > 0xfd || $second > 0xfd ) &&
+                                               ( ( $second > 0xbf && $third > 0xbf ) ||
+                                                       ( $second < 0xc0 && $third < 0xc0 ) ||
+                                                       ( $second > 0xfd ) ||
+                                                       ( $third > 0xfd ) )
+                                       ) {
                                                # fe and ff are not legal head bytes -- expect three replacement chars
                                                $this->assertEquals(
                                                        bin2hex( $head . UTF8_REPLACEMENT . UTF8_REPLACEMENT . UTF8_REPLACEMENT . $tail ),
                                                        bin2hex( $clean ),
                                                        "Forbidden triplet $x should be rejected" );
-                                       } elseif( $first > 0xc2 && $second < 0xc0 && $third < 0xc0 ) {
+                                       } elseif ( $first > 0xc2 && $second < 0xc0 && $third < 0xc0 ) {
                                                $this->assertEquals(
                                                        bin2hex( $head . UTF8_REPLACEMENT . $tail ),
                                                        bin2hex( $clean ),
@@ -251,20 +273,20 @@ class CleanUpTest extends MediaWikiTestCase {
        /** @todo document */
        function testChunkRegression() {
                # Check for regression against a chunking bug
-               $text   = "\x46\x55\xb8" .
-                         "\xdc\x96" .
-                         "\xee" .
-                         "\xe7" .
-                         "\x44" .
-                         "\xaa" .
-                         "\x2f\x25";
+               $text = "\x46\x55\xb8" .
+                       "\xdc\x96" .
+                       "\xee" .
+                       "\xe7" .
+                       "\x44" .
+                       "\xaa" .
+                       "\x2f\x25";
                $expect = "\x46\x55\xef\xbf\xbd" .
-                         "\xdc\x96" .
-                         "\xef\xbf\xbd" .
-                         "\xef\xbf\xbd" .
-                         "\x44" .
-                         "\xef\xbf\xbd" .
-                         "\x2f\x25";
+                       "\xdc\x96" .
+                       "\xef\xbf\xbd" .
+                       "\xef\xbf\xbd" .
+                       "\x44" .
+                       "\xef\xbf\xbd" .
+                       "\x2f\x25";
 
                $this->assertEquals(
                        bin2hex( $expect ),
@@ -273,33 +295,33 @@ class CleanUpTest extends MediaWikiTestCase {
 
        /** @todo document */
        function testInterposeRegression() {
-               $text   = "\x4e\x30" .
-                         "\xb1" .              # bad tail
-                         "\x3a" .
-                         "\x92" .              # bad tail
-                         "\x62\x3a" .
-                         "\x84" .              # bad tail
-                         "\x43" .
-                         "\xc6" .              # bad head
-                         "\x3f" .
-                         "\x92" .              # bad tail
-                         "\xad" .              # bad tail
-                         "\x7d" .
-                         "\xd9\x95";
+               $text = "\x4e\x30" .
+                       "\xb1" . # bad tail
+                       "\x3a" .
+                       "\x92" . # bad tail
+                       "\x62\x3a" .
+                       "\x84" . # bad tail
+                       "\x43" .
+                       "\xc6" . # bad head
+                       "\x3f" .
+                       "\x92" . # bad tail
+                       "\xad" . # bad tail
+                       "\x7d" .
+                       "\xd9\x95";
 
                $expect = "\x4e\x30" .
-                         "\xef\xbf\xbd" .
-                         "\x3a" .
-                         "\xef\xbf\xbd" .
-                         "\x62\x3a" .
-                         "\xef\xbf\xbd" .
-                         "\x43" .
-                         "\xef\xbf\xbd" .
-                         "\x3f" .
-                         "\xef\xbf\xbd" .
-                         "\xef\xbf\xbd" .
-                         "\x7d" .
-                         "\xd9\x95";
+                       "\xef\xbf\xbd" .
+                       "\x3a" .
+                       "\xef\xbf\xbd" .
+                       "\x62\x3a" .
+                       "\xef\xbf\xbd" .
+                       "\x43" .
+                       "\xef\xbf\xbd" .
+                       "\x3f" .
+                       "\xef\xbf\xbd" .
+                       "\xef\xbf\xbd" .
+                       "\x7d" .
+                       "\xd9\x95";
 
                $this->assertEquals(
                        bin2hex( $expect ),
@@ -308,24 +330,24 @@ class CleanUpTest extends MediaWikiTestCase {
 
        /** @todo document */
        function testOverlongRegression() {
-               $text   = "\x67" .
-                         "\x1a" . # forbidden ascii
-                         "\xea" . # bad head
-                         "\xc1\xa6" . # overlong sequence
-                         "\xad" . # bad tail
-                         "\x1c" . # forbidden ascii
-                         "\xb0" . # bad tail
-                         "\x3c" .
-                         "\x9e";  # bad tail
+               $text = "\x67" .
+                       "\x1a" . # forbidden ascii
+                       "\xea" . # bad head
+                       "\xc1\xa6" . # overlong sequence
+                       "\xad" . # bad tail
+                       "\x1c" . # forbidden ascii
+                       "\xb0" . # bad tail
+                       "\x3c" .
+                       "\x9e"; # bad tail
                $expect = "\x67" .
-                         "\xef\xbf\xbd" .
-                         "\xef\xbf\xbd" .
-                         "\xef\xbf\xbd" .
-                         "\xef\xbf\xbd" .
-                         "\xef\xbf\xbd" .
-                         "\xef\xbf\xbd" .
-                         "\x3c" .
-                         "\xef\xbf\xbd";
+                       "\xef\xbf\xbd" .
+                       "\xef\xbf\xbd" .
+                       "\xef\xbf\xbd" .
+                       "\xef\xbf\xbd" .
+                       "\xef\xbf\xbd" .
+                       "\xef\xbf\xbd" .
+                       "\x3c" .
+                       "\xef\xbf\xbd";
                $this->assertEquals(
                        bin2hex( $expect ),
                        bin2hex( UtfNormal::cleanUp( $text ) ) );
@@ -333,14 +355,14 @@ class CleanUpTest extends MediaWikiTestCase {
 
        /** @todo document */
        function testSurrogateRegression() {
-               $text   = "\xed\xb4\x96" . # surrogate 0xDD16
-                         "\x83" . # bad tail
-                         "\xb4" . # bad tail
-                         "\xac";  # bad head
+               $text = "\xed\xb4\x96" . # surrogate 0xDD16
+                       "\x83" . # bad tail
+                       "\xb4" . # bad tail
+                       "\xac"; # bad head
                $expect = "\xef\xbf\xbd" .
-                         "\xef\xbf\xbd" .
-                         "\xef\xbf\xbd" .
-                         "\xef\xbf\xbd";
+                       "\xef\xbf\xbd" .
+                       "\xef\xbf\xbd" .
+                       "\xef\xbf\xbd";
                $this->assertEquals(
                        bin2hex( $expect ),
                        bin2hex( UtfNormal::cleanUp( $text ) ) );
@@ -348,14 +370,14 @@ class CleanUpTest extends MediaWikiTestCase {
 
        /** @todo document */
        function testBomRegression() {
-               $text   = "\xef\xbf\xbe" . # U+FFFE, illegal char
-                         "\xb2" . # bad tail
-                         "\xef" . # bad head
-                         "\x59";
+               $text = "\xef\xbf\xbe" . # U+FFFE, illegal char
+                       "\xb2" . # bad tail
+                       "\xef" . # bad head
+                       "\x59";
                $expect = "\xef\xbf\xbd" .
-                         "\xef\xbf\xbd" .
-                         "\xef\xbf\xbd" .
-                         "\x59";
+                       "\xef\xbf\xbd" .
+                       "\xef\xbf\xbd" .
+                       "\x59";
                $this->assertEquals(
                        bin2hex( $expect ),
                        bin2hex( UtfNormal::cleanUp( $text ) ) );
@@ -363,7 +385,7 @@ class CleanUpTest extends MediaWikiTestCase {
 
        /** @todo document */
        function testForbiddenRegression() {
-               $text   = "\xef\xbf\xbf"; # U+FFFF, illegal char
+               $text = "\xef\xbf\xbf"; # U+FFFF, illegal char
                $expect = "\xef\xbf\xbd";
                $this->assertEquals(
                        bin2hex( $expect ),
@@ -373,8 +395,8 @@ class CleanUpTest extends MediaWikiTestCase {
        /** @todo document */
        function testHangulRegression() {
                $text = "\xed\x9c\xaf" . # Hangul char
-                               "\xe1\x87\x81";  # followed by another final jamo
-               $expect = $text;         # Should *not* change.
+                       "\xe1\x87\x81"; # followed by another final jamo
+               $expect = $text; # Should *not* change.
                $this->assertEquals(
                        bin2hex( $expect ),
                        bin2hex( UtfNormal::cleanUp( $text ) ) );
index f5264be..f3dd0a0 100644 (file)
@@ -15,9 +15,8 @@ class BagOStuffTest extends MediaWikiTestCase {
                        $name = $this->getCliArg( 'use-bagostuff=' );
 
                        $this->cache = ObjectCache::newFromId( $name );
-
-               // no type defined - use simple hash
                } else {
+                       // no type defined - use simple hash
                        $this->cache = new HashBagOStuff;
                }
 
@@ -41,7 +40,7 @@ class BagOStuffTest extends MediaWikiTestCase {
                 * @use int $usleep
                 * @return int
                 */
-               $callback = function( BagOStuff $cache, $key, $existingValue ) use ( &$usleep ) {
+               $callback = function ( BagOStuff $cache, $key, $existingValue ) use ( &$usleep ) {
                        // let's pretend this is an expensive callback to test concurrent merge attempts
                        usleep( $usleep );
 
index c82ae9b..dfcdafd 100644 (file)
@@ -69,14 +69,17 @@ class MagicVariableTest extends MediaWikiTestCase {
        function testCurrentdayIsUnPadded( $day ) {
                $this->assertUnPadded( 'currentday', $day );
        }
+
        /** @dataProvider MediaWikiProvide::Days */
        function testCurrentdaytwoIsZeroPadded( $day ) {
                $this->assertZeroPadded( 'currentday2', $day );
        }
+
        /** @dataProvider MediaWikiProvide::Days */
        function testLocaldayIsUnPadded( $day ) {
                $this->assertUnPadded( 'localday', $day );
        }
+
        /** @dataProvider MediaWikiProvide::Days */
        function testLocaldaytwoIsZeroPadded( $day ) {
                $this->assertZeroPadded( 'localday2', $day );
@@ -88,14 +91,17 @@ class MagicVariableTest extends MediaWikiTestCase {
        function testCurrentmonthIsZeroPadded( $month ) {
                $this->assertZeroPadded( 'currentmonth', $month );
        }
+
        /** @dataProvider MediaWikiProvide::Months */
        function testCurrentmonthoneIsUnPadded( $month ) {
                $this->assertUnPadded( 'currentmonth1', $month );
        }
+
        /** @dataProvider MediaWikiProvide::Months */
        function testLocalmonthIsZeroPadded( $month ) {
                $this->assertZeroPadded( 'localmonth', $month );
        }
+
        /** @dataProvider MediaWikiProvide::Months */
        function testLocalmonthoneIsUnPadded( $month ) {
                $this->assertUnPadded( 'localmonth1', $month );
@@ -108,6 +114,7 @@ class MagicVariableTest extends MediaWikiTestCase {
        function testRevisiondayIsUnPadded( $day ) {
                $this->assertUnPadded( 'revisionday', $day );
        }
+
        /** @dataProvider MediaWikiProvide::Days */
        function testRevisiondaytwoIsZeroPadded( $day ) {
                $this->assertZeroPadded( 'revisionday2', $day );
@@ -119,6 +126,7 @@ class MagicVariableTest extends MediaWikiTestCase {
        function testRevisionmonthIsZeroPadded( $month ) {
                $this->assertZeroPadded( 'revisionmonth', $month );
        }
+
        /** @dataProvider MediaWikiProvide::Months */
        function testRevisionmonthoneIsUnPadded( $month ) {
                $this->assertUnPadded( 'revisionmonth1', $month );
@@ -130,13 +138,13 @@ class MagicVariableTest extends MediaWikiTestCase {
         */
        function testServernameFromDifferentProtocols() {
                global $wgServer;
-               $saved_wgServer= $wgServer;
+               $saved_wgServer = $wgServer;
 
                $wgServer = 'http://localhost/';
                $this->assertMagic( 'localhost', 'servername' );
                $wgServer = 'https://localhost/';
                $this->assertMagic( 'localhost', 'servername' );
-               $wgServer = '//localhost/';  # bug 31176
+               $wgServer = '//localhost/'; # bug 31176
                $this->assertMagic( 'localhost', 'servername' );
 
                $wgServer = $saved_wgServer;
@@ -163,8 +171,11 @@ class MagicVariableTest extends MediaWikiTestCase {
        private function assertMagicPadding( $magic, $value, $format ) {
                # Initialize parser timestamp as year 2010 at 12h34 56s.
                # month and day are given by the caller ($value). Month < 12!
-               if( $value > 12 ) { $month = $value % 12; }
-               else { $month = $value; }
+               if ( $value > 12 ) {
+                       $month = $value % 12;
+               } else {
+                       $month = $value;
+               }
 
                $this->setParserTS(
                        sprintf( '2010%02d%02d123456', $month, $value )
@@ -188,7 +199,7 @@ class MagicVariableTest extends MediaWikiTestCase {
         * Assertion helper to test a magic variable output
         */
        private function assertMagic( $expected, $magic ) {
-               if( in_array( $magic, $this->expectedAsInteger ) ) {
+               if ( in_array( $magic, $this->expectedAsInteger ) ) {
                        $expected = (int)$expected;
                }
 
index 013b02c..067a7c4 100644 (file)
@@ -3,9 +3,9 @@ require_once( __DIR__ . '/NewParserTest.php' );
 
 /**
  * The UnitTest must be either a class that inherits from MediaWikiTestCase
- * or a class that provides a public static suite() method which returns 
+ * or a class that provides a public static suite() method which returns
  * an PHPUnit_Framework_Test object
- * 
+ *
  * @group Parser
  * @group Database
  */
index 3e3b141..5c7597e 100644 (file)
@@ -8,7 +8,7 @@
  * @group Stub
  */
 class NewParserTest extends MediaWikiTestCase {
-       static protected $articles = array();   // Array of test articles defined by the tests
+       static protected $articles = array(); // Array of test articles defined by the tests
        /* The data provider is run on a different instance than the test, so it must be static
         * When running tests from several files, all tests will see all articles.
         */
@@ -60,12 +60,12 @@ class NewParserTest extends MediaWikiTestCase {
                $tmpGlobals['wgStylePath'] = '/skins';
                $tmpGlobals['wgThumbnailScriptPath'] = false;
                $tmpGlobals['wgLocalFileRepo'] = array(
-                       'class'           => 'LocalRepo',
-                       'name'            => 'local',
-                       'url'             => 'http://example.com/images',
-                       'hashLevels'      => 2,
+                       'class' => 'LocalRepo',
+                       'name' => 'local',
+                       'url' => 'http://example.com/images',
+                       'hashLevels' => 2,
                        'transformVia404' => false,
-                       'backend'         => 'local-backend'
+                       'backend' => 'local-backend'
                );
                $tmpGlobals['wgForeignFileRepos'] = array();
                $tmpGlobals['wgEnableParserCache'] = false;
@@ -132,44 +132,43 @@ class NewParserTest extends MediaWikiTestCase {
                # Hack: insert a few Wikipedia in-project interwiki prefixes,
                # for testing inter-language links
                $this->db->insert( 'interwiki', array(
-                       array( 'iw_prefix' => 'wikipedia',
-                                  'iw_url'    => 'http://en.wikipedia.org/wiki/$1',
-                                  'iw_api'    => '',
-                                  'iw_wikiid' => '',
-                                  'iw_local'  => 0 ),
-                       array( 'iw_prefix' => 'meatball',
-                                  'iw_url'    => 'http://www.usemod.com/cgi-bin/mb.pl?$1',
-                                  'iw_api'    => '',
-                                  'iw_wikiid' => '',
-                                  'iw_local'  => 0 ),
-                       array( 'iw_prefix' => 'zh',
-                                  'iw_url'    => 'http://zh.wikipedia.org/wiki/$1',
-                                  'iw_api'    => '',
-                                  'iw_wikiid' => '',
-                                  'iw_local'  => 1 ),
-                       array( 'iw_prefix' => 'es',
-                                  'iw_url'    => 'http://es.wikipedia.org/wiki/$1',
-                                  'iw_api'    => '',
-                                  'iw_wikiid' => '',
-                                  'iw_local'  => 1 ),
-                       array( 'iw_prefix' => 'fr',
-                                  'iw_url'    => 'http://fr.wikipedia.org/wiki/$1',
-                                  'iw_api'    => '',
-                                  'iw_wikiid' => '',
-                                  'iw_local'  => 1 ),
-                       array( 'iw_prefix' => 'ru',
-                                  'iw_url'    => 'http://ru.wikipedia.org/wiki/$1',
-                                  'iw_api'    => '',
-                                  'iw_wikiid' => '',
-                                  'iw_local'  => 1 ),
-                       /**
-                        * @todo Fixme! Why are we inserting duplicate data here? Shouldn't
-                        * need this IGNORE or shouldn't need the insert at all.
-                        */
+                               array( 'iw_prefix' => 'wikipedia',
+                                       'iw_url' => 'http://en.wikipedia.org/wiki/$1',
+                                       'iw_api' => '',
+                                       'iw_wikiid' => '',
+                                       'iw_local' => 0 ),
+                               array( 'iw_prefix' => 'meatball',
+                                       'iw_url' => 'http://www.usemod.com/cgi-bin/mb.pl?$1',
+                                       'iw_api' => '',
+                                       'iw_wikiid' => '',
+                                       'iw_local' => 0 ),
+                               array( 'iw_prefix' => 'zh',
+                                       'iw_url' => 'http://zh.wikipedia.org/wiki/$1',
+                                       'iw_api' => '',
+                                       'iw_wikiid' => '',
+                                       'iw_local' => 1 ),
+                               array( 'iw_prefix' => 'es',
+                                       'iw_url' => 'http://es.wikipedia.org/wiki/$1',
+                                       'iw_api' => '',
+                                       'iw_wikiid' => '',
+                                       'iw_local' => 1 ),
+                               array( 'iw_prefix' => 'fr',
+                                       'iw_url' => 'http://fr.wikipedia.org/wiki/$1',
+                                       'iw_api' => '',
+                                       'iw_wikiid' => '',
+                                       'iw_local' => 1 ),
+                               array( 'iw_prefix' => 'ru',
+                                       'iw_url' => 'http://ru.wikipedia.org/wiki/$1',
+                                       'iw_api' => '',
+                                       'iw_wikiid' => '',
+                                       'iw_local' => 1 ),
+                               /**
+                                * @todo Fixme! Why are we inserting duplicate data here? Shouldn't
+                                * need this IGNORE or shouldn't need the insert at all.
+                                */
                        ), __METHOD__, array( 'IGNORE' )
                );
 
-
                # Update certain things in site_stats
                $this->db->insert( 'site_stats',
                        array( 'ss_row_id' => 1, 'ss_images' => 2, 'ss_good_articles' => 1 ),
@@ -196,15 +195,15 @@ class NewParserTest extends MediaWikiTestCase {
                                'Upload of some lame file',
                                'Some lame file',
                                array(
-                                       'size'        => 12345,
-                                       'width'       => 1941,
-                                       'height'      => 220,
-                                       'bits'        => 24,
-                                       'media_type'  => MEDIATYPE_BITMAP,
-                                       'mime'        => 'image/jpeg',
-                                       'metadata'    => serialize( array() ),
-                                       'sha1'        => wfBaseConvert( '', 16, 36, 31 ),
-                                       'fileExists'  => true ),
+                                       'size' => 12345,
+                                       'width' => 1941,
+                                       'height' => 220,
+                                       'bits' => 24,
+                                       'media_type' => MEDIATYPE_BITMAP,
+                                       'mime' => 'image/jpeg',
+                                       'metadata' => serialize( array() ),
+                                       'sha1' => wfBaseConvert( '', 16, 36, 31 ),
+                                       'fileExists' => true ),
                                $this->db->timestamp( '20010115123500' ), $user
                        );
                }
@@ -217,23 +216,20 @@ class NewParserTest extends MediaWikiTestCase {
                                'zomgnotcensored',
                                'Borderline image',
                                array(
-                                       'size'        => 12345,
-                                       'width'       => 320,
-                                       'height'      => 240,
-                                       'bits'        => 24,
-                                       'media_type'  => MEDIATYPE_BITMAP,
-                                       'mime'        => 'image/jpeg',
-                                       'metadata'    => serialize( array() ),
-                                       'sha1'        => wfBaseConvert( '', 16, 36, 31 ),
-                                       'fileExists'  => true ),
+                                       'size' => 12345,
+                                       'width' => 320,
+                                       'height' => 240,
+                                       'bits' => 24,
+                                       'media_type' => MEDIATYPE_BITMAP,
+                                       'mime' => 'image/jpeg',
+                                       'metadata' => serialize( array() ),
+                                       'sha1' => wfBaseConvert( '', 16, 36, 31 ),
+                                       'fileExists' => true ),
                                $this->db->timestamp( '20010115123500' ), $user
                        );
                }
        }
 
-
-
-
        //ParserTest setup/teardown functions
 
        /**
@@ -271,11 +267,11 @@ class NewParserTest extends MediaWikiTestCase {
                        }
                } else {
                        $backend = new FSFileBackend( array(
-                               'name'        => 'local-backend',
+                               'name' => 'local-backend',
                                'lockManager' => 'nullLockManager',
                                'containerPaths' => array(
                                        'local-public' => "$uploadDir",
-                                       'local-thumb'  => "$uploadDir/thumb",
+                                       'local-thumb' => "$uploadDir/thumb",
                                )
                        ) );
                }
@@ -288,12 +284,12 @@ class NewParserTest extends MediaWikiTestCase {
                        'wgExtensionAssetsPath' => '/extensions',
                        'wgActionPaths' => array(),
                        'wgLocalFileRepo' => array(
-                               'class'           => 'LocalRepo',
-                               'name'            => 'local',
-                               'url'             => 'http://example.com/images',
-                               'hashLevels'      => 2,
+                               'class' => 'LocalRepo',
+                               'name' => 'local',
+                               'url' => 'http://example.com/images',
+                               'hashLevels' => 2,
                                'transformVia404' => false,
-                               'backend'         => $backend
+                               'backend' => $backend
                        ),
                        'wgEnableUploads' => self::getOptionValue( 'wgEnableUploads', $opts, true ),
                        'wgStylePath' => '/skins',
@@ -320,10 +316,10 @@ class NewParserTest extends MediaWikiTestCase {
                        'wgVariantArticlePath' => false,
                        'wgGroupPermissions' => array( '*' => array(
                                'createaccount' => true,
-                               'read'          => true,
-                               'edit'          => true,
-                               'createpage'    => true,
-                               'createtalk'    => true,
+                               'read' => true,
+                               'edit' => true,
+                               'createpage' => true,
+                               'createtalk' => true,
                        ) ),
                        'wgNamespaceProtection' => array( NS_MEDIAWIKI => 'editinterface' ),
                        'wgDefaultExternalStore' => array(),
@@ -466,7 +462,7 @@ class NewParserTest extends MediaWikiTestCase {
                $base = $this->getBaseDir();
                // delete the files first, then the dirs.
                self::deleteFiles(
-                       array (
+                       array(
                                "$base/local-public/3/3a/Foobar.jpg",
                                "$base/local-thumb/3/3a/Foobar.jpg/180px-Foobar.jpg",
                                "$base/local-thumb/3/3a/Foobar.jpg/200px-Foobar.jpg",
@@ -545,7 +541,7 @@ class NewParserTest extends MediaWikiTestCase {
                        // @todo: When setting up pages, force the content model. Only skip if
                        //        $wgtContentModelUseDB is false.
                        $this->markTestSkipped( "Main namespace does not support wikitext,"
-                                       . "skipping parser test: $desc" );
+                               . "skipping parser test: $desc" );
                }
 
                wfDebug( "Running parser test: $desc\n" );
@@ -558,8 +554,7 @@ class NewParserTest extends MediaWikiTestCase {
 
                if ( isset( $opts['title'] ) ) {
                        $titleText = $opts['title'];
-               }
-               else {
+               } else {
                        $titleText = 'Parser test';
                }
 
@@ -632,7 +627,7 @@ class NewParserTest extends MediaWikiTestCase {
 
                $files = $wgParserTestFiles;
 
-               if( $this->getCliArg( 'file=' ) ) {
+               if ( $this->getCliArg( 'file=' ) ) {
                        $files = array( $this->getCliArg( 'file=' ) );
                }
 
@@ -794,15 +789,16 @@ class NewParserTest extends MediaWikiTestCase {
         */
        public function requireHook( $name ) {
                global $wgParser;
-               $wgParser->firstCallInit( ); // make sure hooks are loaded.
+               $wgParser->firstCallInit(); // make sure hooks are loaded.
                return isset( $wgParser->mTagHooks[$name] );
        }
 
        public function requireFunctionHook( $name ) {
                global $wgParser;
-               $wgParser->firstCallInit( ); // make sure hooks are loaded.
+               $wgParser->firstCallInit(); // make sure hooks are loaded.
                return isset( $wgParser->mFunctionHooks[$name] );
        }
+
        //Various "cleanup" functions
 
        /**
@@ -828,8 +824,7 @@ class NewParserTest extends MediaWikiTestCase {
        public function removeEndingNewline( $s ) {
                if ( substr( $s, -1 ) === "\n" ) {
                        return substr( $s, 0, -1 );
-               }
-               else {
+               } else {
                        return $s;
                }
        }
index f3a12d0..5c1a268 100644 (file)
@@ -5,10 +5,10 @@ class ParserMethodsTest extends MediaWikiLangTestCase {
        public static function providePreSaveTransform() {
                return array(
                        array( 'hello this is ~~~',
-                              "hello this is [[Special:Contributions/127.0.0.1|127.0.0.1]]",
+                               "hello this is [[Special:Contributions/127.0.0.1|127.0.0.1]]",
                        ),
                        array( 'hello \'\'this\'\' is <nowiki>~~~</nowiki>',
-                              'hello \'\'this\'\' is <nowiki>~~~</nowiki>',
+                               'hello \'\'this\'\' is <nowiki>~~~</nowiki>',
                        ),
                );
        }
index 8c22c59..e16b407 100644 (file)
@@ -57,7 +57,7 @@ class ParserPreloadTest extends MediaWikiTestCase {
                );
        }
 
-       function assertPreloaded( $expected, $text, $msg='') {
+       function assertPreloaded( $expected, $text, $msg = '' ) {
                $this->assertEquals(
                        $expected,
                        $this->testParser->getPreloadText(
index 4b1f519..c51a1dc 100644 (file)
@@ -52,16 +52,16 @@ class PreprocessorTest extends MediaWikiTestCase {
                        array( "Foo\n=\n==\n=\n", "<root>Foo\n=\n==\n=\n</root>" ),
                        array( "{{Foo}}", "<root><template><title>Foo</title></template></root>" ),
                        array( "\n{{Foo}}", "<root>\n<template lineStart=\"1\"><title>Foo</title></template></root>" ),
-                       array( "{{Foo|bar}}", "<root><template><title>Foo</title><part><name index=\"1\" /><value>bar</value></part></template></root>" ),  
-                       array( "{{Foo|bar}}a", "<root><template><title>Foo</title><part><name index=\"1\" /><value>bar</value></part></template>a</root>" ),  
-                       array( "{{Foo|bar|baz}}", "<root><template><title>Foo</title><part><name index=\"1\" /><value>bar</value></part><part><name index=\"2\" /><value>baz</value></part></template></root>" ),  
+                       array( "{{Foo|bar}}", "<root><template><title>Foo</title><part><name index=\"1\" /><value>bar</value></part></template></root>" ),
+                       array( "{{Foo|bar}}a", "<root><template><title>Foo</title><part><name index=\"1\" /><value>bar</value></part></template>a</root>" ),
+                       array( "{{Foo|bar|baz}}", "<root><template><title>Foo</title><part><name index=\"1\" /><value>bar</value></part><part><name index=\"2\" /><value>baz</value></part></template></root>" ),
                        array( "{{Foo|1=bar}}", "<root><template><title>Foo</title><part><name>1</name>=<value>bar</value></part></template></root>" ),
                        array( "{{Foo|=bar}}", "<root><template><title>Foo</title><part><name></name>=<value>bar</value></part></template></root>" ),
-                       array( "{{Foo|bar=baz}}", "<root><template><title>Foo</title><part><name>bar</name>=<value>baz</value></part></template></root>" ), 
+                       array( "{{Foo|bar=baz}}", "<root><template><title>Foo</title><part><name>bar</name>=<value>baz</value></part></template></root>" ),
                        array( "{{Foo|{{bar}}=baz}}", "<root><template><title>Foo</title><part><name><template><title>bar</title></template></name>=<value>baz</value></part></template></root>" ),
-                       array( "{{Foo|1=bar|baz}}", "<root><template><title>Foo</title><part><name>1</name>=<value>bar</value></part><part><name index=\"1\" /><value>baz</value></part></template></root>" ), 
+                       array( "{{Foo|1=bar|baz}}", "<root><template><title>Foo</title><part><name>1</name>=<value>bar</value></part><part><name index=\"1\" /><value>baz</value></part></template></root>" ),
                        array( "{{Foo|1=bar|2=baz}}", "<root><template><title>Foo</title><part><name>1</name>=<value>bar</value></part><part><name>2</name>=<value>baz</value></part></template></root>" ),
-                       array( "{{Foo|bar|foo=baz}}", "<root><template><title>Foo</title><part><name index=\"1\" /><value>bar</value></part><part><name>foo</name>=<value>baz</value></part></template></root>" ), 
+                       array( "{{Foo|bar|foo=baz}}", "<root><template><title>Foo</title><part><name index=\"1\" /><value>bar</value></part><part><name>foo</name>=<value>baz</value></part></template></root>" ),
                        array( "{{{1}}}", "<root><tplarg><title>1</title></tplarg></root>" ),
                        array( "{{{1|}}}", "<root><tplarg><title>1</title><part><name index=\"1\" /><value></value></part></tplarg></root>" ),
                        array( "{{{Foo}}}", "<root><tplarg><title>Foo</title></tplarg></root>" ),
@@ -84,26 +84,26 @@ class PreprocessorTest extends MediaWikiTestCase {
                        array( "Foo <gallery bar=\"baz\" />", "<root>Foo <ext><name>gallery</name><attr> bar=&quot;baz&quot; </attr></ext></root>" ),
                        array( "Foo <gallery bar=\"1\" baz=2 />", "<root>Foo <ext><name>gallery</name><attr> bar=&quot;1&quot; baz=2 </attr></ext></root>" ),
                        array( "</foo>Foo<//foo>", "<root><ext><name>/foo</name><attr></attr><inner>Foo</inner><close>&lt;//foo&gt;</close></ext></root>" ), # Worth blacklisting IMHO
-                       array( "{{#ifexpr: ({{{1|1}}} = 2) | Foo | Bar }}", "<root><template><title>#ifexpr: (<tplarg><title>1</title><part><name index=\"1\" /><value>1</value></part></tplarg> = 2) </title><part><name index=\"1\" /><value> Foo </value></part><part><name index=\"2\" /><value> Bar </value></part></template></root>"),
-                       array( "{{#if: {{{1|}}} | Foo | {{Bar}} }}", "<root><template><title>#if: <tplarg><title>1</title><part><name index=\"1\" /><value></value></part></tplarg> </title><part><name index=\"1\" /><value> Foo </value></part><part><name index=\"2\" /><value> <template><title>Bar</title></template> </value></part></template></root>"),
-                       array( "{{#if: {{{1|}}} | Foo | [[Bar]] }}", "<root><template><title>#if: <tplarg><title>1</title><part><name index=\"1\" /><value></value></part></tplarg> </title><part><name index=\"1\" /><value> Foo </value></part><part><name index=\"2\" /><value> [[Bar]] </value></part></template></root>"),
-                       array( "{{#if: {{{1|}}} | [[Foo]] | Bar }}", "<root><template><title>#if: <tplarg><title>1</title><part><name index=\"1\" /><value></value></part></tplarg> </title><part><name index=\"1\" /><value> [[Foo]] </value></part><part><name index=\"2\" /><value> Bar </value></part></template></root>"),
-                       array( "{{#if: {{{1|}}} | 1 | {{#if: {{{1|}}} | 2 | 3 }} }}", "<root><template><title>#if: <tplarg><title>1</title><part><name index=\"1\" /><value></value></part></tplarg> </title><part><name index=\"1\" /><value> 1 </value></part><part><name index=\"2\" /><value> <template><title>#if: <tplarg><title>1</title><part><name index=\"1\" /><value></value></part></tplarg> </title><part><name index=\"1\" /><value> 2 </value></part><part><name index=\"2\" /><value> 3 </value></part></template> </value></part></template></root>"),
-                       array( "{{ {{Foo}}", "<root>{{ <template><title>Foo</title></template></root>"),
-                       array( "{{Foobar {{Foo}} {{Bar}} {{Baz}} ", "<root>{{Foobar <template><title>Foo</title></template> <template><title>Bar</title></template> <template><title>Baz</title></template> </root>"),
-                       array( "[[Foo]] |", "<root>[[Foo]] |</root>"),
-                       array( "{{Foo|Bar|", "<root>{{Foo|Bar|</root>"),
-                       array( "[[Foo]", "<root>[[Foo]</root>"),
-                       array( "[[Foo|Bar]", "<root>[[Foo|Bar]</root>"),
-                       array( "{{Foo| [[Bar] }}", "<root>{{Foo| [[Bar] }}</root>"),
-                       array( "{{Foo| [[Bar|Baz] }}", "<root>{{Foo| [[Bar|Baz] }}</root>"),
-                       array( "{{Foo|bar=[[baz]}}", "<root>{{Foo|bar=[[baz]}}</root>"),
-                       array( "{{foo|", "<root>{{foo|</root>"),
-                       array( "{{foo|}", "<root>{{foo|}</root>"),
-                       array( "{{foo|} }}", "<root><template><title>foo</title><part><name index=\"1\" /><value>} </value></part></template></root>"),
-                       array( "{{foo|bar=|}", "<root>{{foo|bar=|}</root>"),
-                       array( "{{Foo|} Bar=", "<root>{{Foo|} Bar=</root>"),
-                       array( "{{Foo|} Bar=}}", "<root><template><title>Foo</title><part><name>} Bar</name>=<value></value></part></template></root>"),
+                       array( "{{#ifexpr: ({{{1|1}}} = 2) | Foo | Bar }}", "<root><template><title>#ifexpr: (<tplarg><title>1</title><part><name index=\"1\" /><value>1</value></part></tplarg> = 2) </title><part><name index=\"1\" /><value> Foo </value></part><part><name index=\"2\" /><value> Bar </value></part></template></root>" ),
+                       array( "{{#if: {{{1|}}} | Foo | {{Bar}} }}", "<root><template><title>#if: <tplarg><title>1</title><part><name index=\"1\" /><value></value></part></tplarg> </title><part><name index=\"1\" /><value> Foo </value></part><part><name index=\"2\" /><value> <template><title>Bar</title></template> </value></part></template></root>" ),
+                       array( "{{#if: {{{1|}}} | Foo | [[Bar]] }}", "<root><template><title>#if: <tplarg><title>1</title><part><name index=\"1\" /><value></value></part></tplarg> </title><part><name index=\"1\" /><value> Foo </value></part><part><name index=\"2\" /><value> [[Bar]] </value></part></template></root>" ),
+                       array( "{{#if: {{{1|}}} | [[Foo]] | Bar }}", "<root><template><title>#if: <tplarg><title>1</title><part><name index=\"1\" /><value></value></part></tplarg> </title><part><name index=\"1\" /><value> [[Foo]] </value></part><part><name index=\"2\" /><value> Bar </value></part></template></root>" ),
+                       array( "{{#if: {{{1|}}} | 1 | {{#if: {{{1|}}} | 2 | 3 }} }}", "<root><template><title>#if: <tplarg><title>1</title><part><name index=\"1\" /><value></value></part></tplarg> </title><part><name index=\"1\" /><value> 1 </value></part><part><name index=\"2\" /><value> <template><title>#if: <tplarg><title>1</title><part><name index=\"1\" /><value></value></part></tplarg> </title><part><name index=\"1\" /><value> 2 </value></part><part><name index=\"2\" /><value> 3 </value></part></template> </value></part></template></root>" ),
+                       array( "{{ {{Foo}}", "<root>{{ <template><title>Foo</title></template></root>" ),
+                       array( "{{Foobar {{Foo}} {{Bar}} {{Baz}} ", "<root>{{Foobar <template><title>Foo</title></template> <template><title>Bar</title></template> <template><title>Baz</title></template> </root>" ),
+                       array( "[[Foo]] |", "<root>[[Foo]] |</root>" ),
+                       array( "{{Foo|Bar|", "<root>{{Foo|Bar|</root>" ),
+                       array( "[[Foo]", "<root>[[Foo]</root>" ),
+                       array( "[[Foo|Bar]", "<root>[[Foo|Bar]</root>" ),
+                       array( "{{Foo| [[Bar] }}", "<root>{{Foo| [[Bar] }}</root>" ),
+                       array( "{{Foo| [[Bar|Baz] }}", "<root>{{Foo| [[Bar|Baz] }}</root>" ),
+                       array( "{{Foo|bar=[[baz]}}", "<root>{{Foo|bar=[[baz]}}</root>" ),
+                       array( "{{foo|", "<root>{{foo|</root>" ),
+                       array( "{{foo|}", "<root>{{foo|}</root>" ),
+                       array( "{{foo|} }}", "<root><template><title>foo</title><part><name index=\"1\" /><value>} </value></part></template></root>" ),
+                       array( "{{foo|bar=|}", "<root>{{foo|bar=|}</root>" ),
+                       array( "{{Foo|} Bar=", "<root>{{Foo|} Bar=</root>" ),
+                       array( "{{Foo|} Bar=}}", "<root><template><title>Foo</title><part><name>} Bar</name>=<value></value></part></template></root>" ),
                        /* array( file_get_contents( __DIR__ . '/QuoteQuran.txt' ), file_get_contents( __DIR__ . '/QuoteQuranExpanded.txt' ) ), */
                );
        }
@@ -181,7 +181,7 @@ class PreprocessorTest extends MediaWikiTestCase {
         * Tests from Bug 28642 · https://bugzilla.wikimedia.org/28642
         */
        function provideHeadings() {
-               return array(   /* These should become headings: */
+               return array( /* These should become headings: */
                        array( "== h ==<!--c1-->", "<root><h level=\"2\" i=\"1\">== h ==<comment>&lt;!--c1--&gt;</comment></h></root>" ),
                        array( "== h ==         <!--c1-->", "<root><h level=\"2\" i=\"1\">== h ==       <comment>&lt;!--c1--&gt;</comment></h></root>" ),
                        array( "== h ==<!--c1-->        ", "<root><h level=\"2\" i=\"1\">== h ==<comment>&lt;!--c1--&gt;</comment>      </h></root>" ),
index 292f13a..ed60079 100644 (file)
@@ -4,13 +4,12 @@
  * @group Parser
  */
 class TagHookTest extends MediaWikiTestCase {
-       
        public static function provideValidNames() {
                return array( array( 'foo' ), array( 'foo-bar' ), array( 'foo_bar' ), array( 'FOO-BAR' ), array( 'foo bar' ) );
        }
 
        public static function provideBadNames() {
-               return array( array( "foo<bar" ), array( "foo>bar" ), array( "foo\nbar" ),  array( "foo\rbar" ) );
+               return array( array( "foo<bar" ), array( "foo>bar" ), array( "foo\nbar" ), array( "foo\rbar" ) );
        }
 
        protected function setUp() {
@@ -25,14 +24,14 @@ class TagHookTest extends MediaWikiTestCase {
        function testTagHooks( $tag ) {
                global $wgParserConf, $wgContLang;
                $parser = new Parser( $wgParserConf );
-               
+
                $parser->setHook( $tag, array( $this, 'tagCallback' ) );
                $parserOutput = $parser->parse( "Foo<$tag>Bar</$tag>Baz", Title::newFromText( 'Test' ), ParserOptions::newFromUserAndLang( new User, $wgContLang ) );
                $this->assertEquals( "<p>FooOneBaz\n</p>", $parserOutput->getText() );
-               
+
                $parser->mPreprocessor = null; # Break the Parser <-> Preprocessor cycle
        }
-       
+
        /**
         * @dataProvider provideBadNames
         * @expectedException MWException
@@ -40,26 +39,26 @@ class TagHookTest extends MediaWikiTestCase {
        function testBadTagHooks( $tag ) {
                global $wgParserConf, $wgContLang;
                $parser = new Parser( $wgParserConf );
-               
+
                $parser->setHook( $tag, array( $this, 'tagCallback' ) );
                $parser->parse( "Foo<$tag>Bar</$tag>Baz", Title::newFromText( 'Test' ), ParserOptions::newFromUserAndLang( new User, $wgContLang ) );
-               $this->fail('Exception not thrown.');
+               $this->fail( 'Exception not thrown.' );
        }
-       
+
        /**
         * @dataProvider provideValidNames
         */
        function testFunctionTagHooks( $tag ) {
                global $wgParserConf, $wgContLang;
                $parser = new Parser( $wgParserConf );
-               
+
                $parser->setFunctionTagHook( $tag, array( $this, 'functionTagCallback' ), 0 );
                $parserOutput = $parser->parse( "Foo<$tag>Bar</$tag>Baz", Title::newFromText( 'Test' ), ParserOptions::newFromUserAndLang( new User, $wgContLang ) );
                $this->assertEquals( "<p>FooOneBaz\n</p>", $parserOutput->getText() );
-               
+
                $parser->mPreprocessor = null; # Break the Parser <-> Preprocessor cycle
        }
-       
+
        /**
         * @dataProvider provideBadNames
         * @expectedException MWException
@@ -67,16 +66,16 @@ class TagHookTest extends MediaWikiTestCase {
        function testBadFunctionTagHooks( $tag ) {
                global $wgParserConf, $wgContLang;
                $parser = new Parser( $wgParserConf );
-               
+
                $parser->setFunctionTagHook( $tag, array( $this, 'functionTagCallback' ), SFH_OBJECT_ARGS );
                $parser->parse( "Foo<$tag>Bar</$tag>Baz", Title::newFromText( 'Test' ), ParserOptions::newFromUserAndLang( new User, $wgContLang ) );
-               $this->fail('Exception not thrown.');
+               $this->fail( 'Exception not thrown.' );
        }
-       
+
        function tagCallback( $text, $params, $parser ) {
                return str_rot13( $text );
        }
-       
+
        function functionTagCallback( &$parser, $frame, $code, $attribs ) {
                return str_rot13( $code );
        }
index 7339fb8..6abca6d 100644 (file)
@@ -18,10 +18,10 @@ class SearchEngineTest extends MediaWikiLangTestCase {
                # Get database type and version
                $dbType = $this->db->getType();
                $dbSupported =
-                       ($dbType === 'mysql')
-                       || ( $dbType === 'sqlite' && $this->db->getFulltextSearchModule() == 'FTS3' );
+                       ( $dbType === 'mysql' )
+                               || ( $dbType === 'sqlite' && $this->db->getFulltextSearchModule() == 'FTS3' );
 
-               if( !$dbSupported ) {
+               if ( !$dbSupported ) {
                        $this->markTestSkipped( "MySQL or SQLite with FTS3 only" );
                }
 
@@ -49,29 +49,29 @@ class SearchEngineTest extends MediaWikiLangTestCase {
                        return;
                }
 
-               $this->insertPage( "Not_Main_Page",     "This is not a main page", 0 );
-               $this->insertPage( 'Talk:Not_Main_Page',        'This is not a talk page to the main page, see [[smithee]]', 1 );
-               $this->insertPage( 'Smithee',   'A smithee is one who smiths. See also [[Alan Smithee]]', 0 );
-               $this->insertPage( 'Talk:Smithee',      'This article sucks.', 1 );
-               $this->insertPage( 'Unrelated_page',    'Nothing in this page is about the S word.', 0 );
-               $this->insertPage( 'Another_page',      'This page also is unrelated.', 0 );
-               $this->insertPage( 'Help:Help',         'Help me!', 4 );
-               $this->insertPage( 'Thppt',             'Blah blah', 0 );
-               $this->insertPage( 'Alan_Smithee',      'yum', 0 );
-               $this->insertPage( 'Pages',             'are\'food', 0 );
-               $this->insertPage( 'HalfOneUp', 'AZ', 0 );
-               $this->insertPage( 'FullOneUp', 'AZ', 0 );
-               $this->insertPage( 'HalfTwoLow',        'az', 0 );
-               $this->insertPage( 'FullTwoLow',        'az', 0 );
-               $this->insertPage( 'HalfNumbers',       '1234567890', 0 );
-               $this->insertPage( 'FullNumbers',       '1234567890', 0 );
-               $this->insertPage( 'DomainName',        'example.com', 0 );
+               $this->insertPage( "Not_Main_Page", "This is not a main page", 0 );
+               $this->insertPage( 'Talk:Not_Main_Page', 'This is not a talk page to the main page, see [[smithee]]', 1 );
+               $this->insertPage( 'Smithee', 'A smithee is one who smiths. See also [[Alan Smithee]]', 0 );
+               $this->insertPage( 'Talk:Smithee', 'This article sucks.', 1 );
+               $this->insertPage( 'Unrelated_page', 'Nothing in this page is about the S word.', 0 );
+               $this->insertPage( 'Another_page', 'This page also is unrelated.', 0 );
+               $this->insertPage( 'Help:Help', 'Help me!', 4 );
+               $this->insertPage( 'Thppt', 'Blah blah', 0 );
+               $this->insertPage( 'Alan_Smithee', 'yum', 0 );
+               $this->insertPage( 'Pages', 'are\'food', 0 );
+               $this->insertPage( 'HalfOneUp', 'AZ', 0 );
+               $this->insertPage( 'FullOneUp', 'AZ', 0 );
+               $this->insertPage( 'HalfTwoLow', 'az', 0 );
+               $this->insertPage( 'FullTwoLow', 'az', 0 );
+               $this->insertPage( 'HalfNumbers', '1234567890', 0 );
+               $this->insertPage( 'FullNumbers', '1234567890', 0 );
+               $this->insertPage( 'DomainName', 'example.com', 0 );
        }
 
        function fetchIds( $results ) {
                if ( !$this->isWikitextNS( NS_MAIN ) ) {
                        $this->markTestIncomplete( __CLASS__ . " does no yet support non-wikitext content "
-                               . "in the main namespace");
+                               . "in the main namespace" );
                }
 
                $this->assertTrue( is_object( $results ) );
@@ -135,9 +135,9 @@ class SearchEngineTest extends MediaWikiLangTestCase {
 
        function testTextSearch() {
                $this->assertEquals(
-                               array( 'Smithee' ),
-                               $this->fetchIds( $this->search->searchText( 'smithee' ) ),
-                               "Plain search failed" );
+                       array( 'Smithee' ),
+                       $this->fetchIds( $this->search->searchText( 'smithee' ) ),
+                       "Plain search failed" );
        }
 
        function testTextPowerSearch() {
index 0307d4d..c329839 100644 (file)
@@ -80,8 +80,7 @@ class SiteListTest extends MediaWikiTestCase {
        public function testGetSiteByGlobalId( SiteList $sites ) {
                if ( $sites->isEmpty() ) {
                        $this->assertTrue( true );
-               }
-               else {
+               } else {
                        /**
                         * @var Site $site
                         */
index c11165b..d20e2a5 100644 (file)
@@ -244,8 +244,7 @@ class SiteTest extends MediaWikiTestCase {
        protected function assertTypeOrFalse( $type, $value ) {
                if ( $value === false ) {
                        $this->assertTrue( true );
-               }
-               else {
+               } else {
                        $this->assertInternalType( $type, $value );
                }
        }
index a33c7b6..3b82e07 100644 (file)
@@ -39,9 +39,9 @@ class QueryAllSpecialPagesTest extends MediaWikiTestCase {
                parent::__construct();
 
                global $wgQueryPages;
-               foreach( $wgQueryPages as $page ) {
+               foreach ( $wgQueryPages as $page ) {
                        $class = $page[0];
-                       if( ! in_array( $class, $this->manualTest ) ) {
+                       if ( !in_array( $class, $this->manualTest ) ) {
                                $this->queryPages[$class] = new $class;
                        }
                }
@@ -54,22 +54,22 @@ class QueryAllSpecialPagesTest extends MediaWikiTestCase {
        function testQuerypageSqlQuery() {
                global $wgDBtype;
 
-               foreach( $this->queryPages as $page ) {
+               foreach ( $this->queryPages as $page ) {
 
                        // With MySQL, skips special pages reopening a temporary table
                        // See http://bugs.mysql.com/bug.php?id=10327
-                       if(
+                       if (
                                $wgDBtype === 'mysql'
                                && in_array( $page->getName(), $this->reopensTempTable )
                        ) {
-                                       $this->markTestSkipped( "SQL query for page {$page->getName()} can not be tested on MySQL backend (it reopens a temporary table)" );
-                                       continue;
-                               }
+                               $this->markTestSkipped( "SQL query for page {$page->getName()} can not be tested on MySQL backend (it reopens a temporary table)" );
+                               continue;
+                       }
 
-                       $msg = "SQL query for page {$page->getName()} should give a result wrapper object" ;
+                       $msg = "SQL query for page {$page->getName()} should give a result wrapper object";
 
                        $result = $page->reallyDoQuery( 50 );
-                       if( $result instanceof ResultWrapper ) {
+                       if ( $result instanceof ResultWrapper ) {
                                $this->assertTrue( true, $msg );
                        } else {
                                $this->assertFalse( false, $msg );
index 11492a1..add830b 100644 (file)
@@ -41,7 +41,7 @@ class SpecialRecentchangesTest extends MediaWikiTestCase {
 
        /** return false if condition begin with 'rc_timestamp ' */
        private static function filterOutRcTimestampCondition( $var ) {
-               return (false === strpos( $var, 'rc_timestamp ' ));
+               return ( false === strpos( $var, 'rc_timestamp ' ) );
 
        }
 
@@ -70,7 +70,7 @@ class SpecialRecentchangesTest extends MediaWikiTestCase {
                                'namespace' => NS_MAIN,
                                'invert' => 1,
                        ),
-                 "rc conditions with namespace inverted"
+                       "rc conditions with namespace inverted"
                );
        }
 
@@ -89,7 +89,7 @@ class SpecialRecentchangesTest extends MediaWikiTestCase {
                                'namespace' => $ns1,
                                'associated' => 1,
                        ),
-                 "rc conditions with namespace inverted"
+                       "rc conditions with namespace inverted"
                );
        }
 
@@ -105,11 +105,11 @@ class SpecialRecentchangesTest extends MediaWikiTestCase {
                                1 => sprintf( "(rc_namespace != '%s' AND rc_namespace != '%s')", $ns1, $ns2 ),
                        ),
                        array(
-                               'namespace'  => $ns1,
+                               'namespace' => $ns1,
                                'associated' => 1,
-                               'invert'     => 1,
+                               'invert' => 1,
                        ),
-                 "rc conditions with namespace inverted"
+                       "rc conditions with namespace inverted"
                );
        }
 
@@ -119,8 +119,8 @@ class SpecialRecentchangesTest extends MediaWikiTestCase {
         */
        public static function provideNamespacesAssociations() {
                return array( # (NS => Associated_NS)
-                       array( NS_MAIN, NS_TALK),
-                       array( NS_TALK, NS_MAIN),
+                       array( NS_MAIN, NS_TALK ),
+                       array( NS_TALK, NS_MAIN ),
                );
        }
 
index f6652bc..f5ef0fb 100644 (file)
@@ -32,7 +32,7 @@ class SpecialSearchTest extends MediaWikiTestCase {
                        'ns6'=>true,
                ) ));
                 */
-               $context->setRequest( new FauxRequest( $requested ));
+               $context->setRequest( new FauxRequest( $requested ) );
                $search = new SpecialSearch();
                $search->setContext( $context );
                $search->load();
@@ -45,11 +45,11 @@ class SpecialSearchTest extends MediaWikiTestCase {
                $this->assertEquals(
                        array( /** Expected: */
                                'ProfileName' => $expectedProfile,
-                               'Namespaces'  => $expectedNS,
+                               'Namespaces' => $expectedNS,
                        )
                        , array( /** Actual: */
                                'ProfileName' => $search->getProfile(),
-                               'Namespaces'  => $search->getNamespaces(),
+                               'Namespaces' => $search->getNamespaces(),
                        )
                        , $message
                );
@@ -59,14 +59,14 @@ class SpecialSearchTest extends MediaWikiTestCase {
        function provideSearchOptionsTests() {
                $defaultNS = SearchEngine::defaultNamespaces();
                $EMPTY_REQUEST = array();
-               $NO_USER_PREF  = null;
+               $NO_USER_PREF = null;
 
                return array(
                        /**
                         * Parameters:
-                        *      <Web Request>, <User options>
+                        *     <Web Request>, <User options>
                         * Followed by expected values:
-                        *      <ProfileName>, <NSList>
+                        *     <ProfileName>, <NSList>
                         * Then an optional message.
                         */
                        array(
@@ -76,19 +76,19 @@ class SpecialSearchTest extends MediaWikiTestCase {
                        ),
                        array(
                                array( 'ns5' => 1 ), $NO_USER_PREF,
-                               'advanced', array(  5),
+                               'advanced', array( ),
                                'Web request with specific NS should override user preference'
                        ),
                        array(
                                $EMPTY_REQUEST, array(
-                                       'searchNs2' => 1,
-                                       'searchNs14' => 1,
-                               ) + array_fill_keys( array_map( function( $ns ) {
-                                       return "searchNs$ns";
-                               }, $defaultNS ), 0 ),
+                               'searchNs2' => 1,
+                               'searchNs14' => 1,
+                       ) + array_fill_keys( array_map( function ( $ns ) {
+                               return "searchNs$ns";
+                       }, $defaultNS ), 0 ),
                                'advanced', array( 2, 14 ),
                                'Bug 33583: search with no option should honor User search preferences'
-                               . ' and have all other namespace disabled'
+                                       . ' and have all other namespace disabled'
                        ),
                );
        }
@@ -98,11 +98,11 @@ class SpecialSearchTest extends MediaWikiTestCase {
         * User remains anonymous though
         */
        function newUserWithSearchNS( $opt = null ) {
-               $u = User::newFromId(0);
-               if( $opt === null ) {
+               $u = User::newFromId( 0 );
+               if ( $opt === null ) {
                        return $u;
                }
-               foreach($opt as $name => $value) {
+               foreach ( $opt as $name => $value ) {
                        $u->setOption( $name, $value );
                }
                return $u;
@@ -116,7 +116,7 @@ class SpecialSearchTest extends MediaWikiTestCase {
 
                # Initialize [[Special::Search]]
                $search = new SpecialSearch();
-               $search->getContext()->setTitle( Title::newFromText('Special:Search' ) );
+               $search->getContext()->setTitle( Title::newFromText( 'Special:Search' ) );
                $search->load();
 
                # Simulate a user searching for a given term