6 of n.
Change-Id: I0ca3f1f72349623631ce1d7f3a4e2ed5edbdbdf4
*/
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 ),
/** @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;
+ }
}
}
}
* @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;
+ }
}
}
}
/** @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 ),
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 ),
/** @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 ),
/** @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 ),
/** @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 ) ) );
/** @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 ) ) );
/** @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 ) ) );
/** @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 ),
/** @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 ) ) );
$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;
}
* @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 );
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 );
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 );
function testRevisiondayIsUnPadded( $day ) {
$this->assertUnPadded( 'revisionday', $day );
}
+
/** @dataProvider MediaWikiProvide::Days */
function testRevisiondaytwoIsZeroPadded( $day ) {
$this->assertZeroPadded( 'revisionday2', $day );
function testRevisionmonthIsZeroPadded( $month ) {
$this->assertZeroPadded( 'revisionmonth', $month );
}
+
/** @dataProvider MediaWikiProvide::Months */
function testRevisionmonthoneIsUnPadded( $month ) {
$this->assertUnPadded( 'revisionmonth1', $month );
*/
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;
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 )
* 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;
}
/**
* 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
*/
* @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.
*/
$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;
# 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 ),
'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
);
}
'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
/**
}
} 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",
)
) );
}
'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',
'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(),
$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",
// @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" );
if ( isset( $opts['title'] ) ) {
$titleText = $opts['title'];
- }
- else {
+ } else {
$titleText = 'Parser test';
}
$files = $wgParserTestFiles;
- if( $this->getCliArg( 'file=' ) ) {
+ if ( $this->getCliArg( 'file=' ) ) {
$files = array( $this->getCliArg( 'file=' ) );
}
*/
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
/**
public function removeEndingNewline( $s ) {
if ( substr( $s, -1 ) === "\n" ) {
return substr( $s, 0, -1 );
- }
- else {
+ } else {
return $s;
}
}
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>',
),
);
}
);
}
- function assertPreloaded( $expected, $text, $msg='') {
+ function assertPreloaded( $expected, $text, $msg = '' ) {
$this->assertEquals(
$expected,
$this->testParser->getPreloadText(
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>" ),
array( "Foo <gallery bar=\"baz\" />", "<root>Foo <ext><name>gallery</name><attr> bar="baz" </attr></ext></root>" ),
array( "Foo <gallery bar=\"1\" baz=2 />", "<root>Foo <ext><name>gallery</name><attr> bar="1" baz=2 </attr></ext></root>" ),
array( "</foo>Foo<//foo>", "<root><ext><name>/foo</name><attr></attr><inner>Foo</inner><close><//foo></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' ) ), */
);
}
* 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><!--c1--></comment></h></root>" ),
array( "== h == <!--c1-->", "<root><h level=\"2\" i=\"1\">== h == <comment><!--c1--></comment></h></root>" ),
array( "== h ==<!--c1--> ", "<root><h level=\"2\" i=\"1\">== h ==<comment><!--c1--></comment> </h></root>" ),
* @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() {
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
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
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 );
}
# 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" );
}
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 ) );
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() {
public function testGetSiteByGlobalId( SiteList $sites ) {
if ( $sites->isEmpty() ) {
$this->assertTrue( true );
- }
- else {
+ } else {
/**
* @var Site $site
*/
protected function assertTypeOrFalse( $type, $value ) {
if ( $value === false ) {
$this->assertTrue( true );
- }
- else {
+ } else {
$this->assertInternalType( $type, $value );
}
}
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;
}
}
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 );
/** 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 ' ) );
}
'namespace' => NS_MAIN,
'invert' => 1,
),
- "rc conditions with namespace inverted"
+ "rc conditions with namespace inverted"
);
}
'namespace' => $ns1,
'associated' => 1,
),
- "rc conditions with namespace inverted"
+ "rc conditions with namespace inverted"
);
}
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"
);
}
*/
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 ),
);
}
'ns6'=>true,
) ));
*/
- $context->setRequest( new FauxRequest( $requested ));
+ $context->setRequest( new FauxRequest( $requested ) );
$search = new SpecialSearch();
$search->setContext( $context );
$search->load();
$this->assertEquals(
array( /** Expected: */
'ProfileName' => $expectedProfile,
- 'Namespaces' => $expectedNS,
+ 'Namespaces' => $expectedNS,
)
, array( /** Actual: */
'ProfileName' => $search->getProfile(),
- 'Namespaces' => $search->getNamespaces(),
+ 'Namespaces' => $search->getNamespaces(),
)
, $message
);
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(
),
array(
array( 'ns5' => 1 ), $NO_USER_PREF,
- 'advanced', array( 5),
+ 'advanced', array( 5 ),
'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'
),
);
}
* 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;
# 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