-
-
-
-
- The interwebs
-
-
-
- Bawolff
-
-
- A file to test GIF
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-EOF;
- $xmpNugget = str_replace( "\r", '', $xmpNugget ); // Windows compat
-
- return array(
- array( 'nonanimated.gif', array(
- 'comment' => array( 'GIF test file ⁕ Created with GIMP' ),
- 'duration' => 0.1,
- 'frameCount' => 1,
- 'looped' => false,
- 'xmp' => '',
- )
- ),
- array( 'animated.gif', array(
- 'comment' => array( 'GIF test file . Created with GIMP' ),
- 'duration' => 2.4,
- 'frameCount' => 4,
- 'looped' => true,
- 'xmp' => '',
- )
- ),
-
- array( 'animated-xmp.gif', array(
- 'xmp' => $xmpNugget,
- 'duration' => 2.4,
- 'frameCount' => 4,
- 'looped' => true,
- 'comment' => array( 'GIƒ·test·file' ),
- )
- ),
- );
- }
-}
diff --git a/tests/phpunit/includes/media/GIFTest.php b/tests/phpunit/includes/media/GIFTest.php
deleted file mode 100644
index 5dcbeee0..00000000
--- a/tests/phpunit/includes/media/GIFTest.php
+++ /dev/null
@@ -1,98 +0,0 @@
-filePath = __DIR__ . '/../../data/media';
- $this->backend = new FSFileBackend( array(
- 'name' => 'localtesting',
- 'lockManager' => 'nullLockManager',
- 'containerPaths' => array( 'data' => $this->filePath )
- ) );
- $this->repo = new FSRepo( array(
- 'name' => 'temp',
- 'url' => 'http://localhost/thumbtest',
- 'backend' => $this->backend
- ) );
- $this->handler = new GIFHandler();
- }
-
- public function testInvalidFile() {
- $res = $this->handler->getMetadata( null, $this->filePath . '/README' );
- $this->assertEquals( GIFHandler::BROKEN_FILE, $res );
- }
- /**
- * @param $filename String basename of the file to check
- * @param $expected boolean Expected result.
- * @dataProvider dataIsAnimated
- */
- public function testIsAnimanted( $filename, $expected ) {
- $file = $this->dataFile( $filename, 'image/gif' );
- $actual = $this->handler->isAnimatedImage( $file );
- $this->assertEquals( $expected, $actual );
- }
- public function dataIsAnimated() {
- return array(
- array( 'animated.gif', true ),
- array( 'nonanimated.gif', false ),
- );
- }
-
- /**
- * @param $filename String
- * @param $expected Integer Total image area
- * @dataProvider dataGetImageArea
- */
- public function testGetImageArea( $filename, $expected ) {
- $file = $this->dataFile( $filename, 'image/gif' );
- $actual = $this->handler->getImageArea( $file, $file->getWidth(), $file->getHeight() );
- $this->assertEquals( $expected, $actual );
- }
- public function dataGetImageArea() {
- return array(
- array( 'animated.gif', 5400 ),
- array( 'nonanimated.gif', 1350 ),
- );
- }
-
- /**
- * @param $metadata String Serialized metadata
- * @param $expected Integer One of the class constants of GIFHandler
- * @dataProvider dataIsMetadataValid
- */
- public function testIsMetadataValid( $metadata, $expected ) {
- $actual = $this->handler->isMetadataValid( null, $metadata );
- $this->assertEquals( $expected, $actual );
- }
- public function dataIsMetadataValid() {
- return array(
- array( GIFHandler::BROKEN_FILE, GIFHandler::METADATA_GOOD ),
- array( '', GIFHandler::METADATA_BAD ),
- array( null, GIFHandler::METADATA_BAD ),
- array( 'Something invalid!', GIFHandler::METADATA_BAD ),
- array( 'a:4:{s:10:"frameCount";i:1;s:6:"looped";b:0;s:8:"duration";d:0.1000000000000000055511151231257827021181583404541015625;s:8:"metadata";a:2:{s:14:"GIFFileComment";a:1:{i:0;s:35:"GIF test file ⁕ Created with GIMP";}s:15:"_MW_GIF_VERSION";i:1;}}', GIFHandler::METADATA_GOOD ),
- );
- }
-
- /**
- * @param $filename String
- * @param $expected String Serialized array
- * @dataProvider dataGetMetadata
- */
- public function testGetMetadata( $filename, $expected ) {
- $file = $this->dataFile( $filename, 'image/gif' );
- $actual = $this->handler->getMetadata( $file, "$this->filePath/$filename" );
- $this->assertEquals( unserialize( $expected ), unserialize( $actual ) );
- }
-
- public function dataGetMetadata() {
- return array(
- array( 'nonanimated.gif', 'a:4:{s:10:"frameCount";i:1;s:6:"looped";b:0;s:8:"duration";d:0.1000000000000000055511151231257827021181583404541015625;s:8:"metadata";a:2:{s:14:"GIFFileComment";a:1:{i:0;s:35:"GIF test file ⁕ Created with GIMP";}s:15:"_MW_GIF_VERSION";i:1;}}' ),
- array( 'animated-xmp.gif', 'a:4:{s:10:"frameCount";i:4;s:6:"looped";b:1;s:8:"duration";d:2.399999999999999911182158029987476766109466552734375;s:8:"metadata";a:5:{s:6:"Artist";s:7:"Bawolff";s:16:"ImageDescription";a:2:{s:9:"x-default";s:18:"A file to test GIF";s:5:"_type";s:4:"lang";}s:15:"SublocationDest";s:13:"The interwebs";s:14:"GIFFileComment";a:1:{i:0;s:16:"GIƒ·test·file";}s:15:"_MW_GIF_VERSION";i:1;}}' ),
- );
- }
-
- private function dataFile( $name, $type ) {
- return new UnregisteredLocalFile( false, $this->repo,
- "mwstore://localtesting/data/$name", $type );
- }
-}
diff --git a/tests/phpunit/includes/media/IPTCTest.php b/tests/phpunit/includes/media/IPTCTest.php
deleted file mode 100644
index ec6deeb8..00000000
--- a/tests/phpunit/includes/media/IPTCTest.php
+++ /dev/null
@@ -1,55 +0,0 @@
-assertEquals( 'UTF-8', $res );
- }
-
- public function testIPTCParseNoCharset88591() {
- // basically IPTC for keyword with value of 0xBC which is 1/4 in iso-8859-1
- // This data doesn't specify a charset. We're supposed to guess
- // (which basically means utf-8 if valid, windows 1252 (iso 8859-1) if not)
- $iptcData = "Photoshop 3.0\08BIM\4\4\0\0\0\0\0\x06\x1c\x02\x19\x00\x01\xBC";
- $res = IPTC::Parse( $iptcData );
- $this->assertEquals( array( '¼' ), $res['Keywords'] );
- }
- /* This one contains a sequence that's valid iso 8859-1 but not valid utf8 */
- /* \xC3 = Ã, \xB8 = ¸ */
- public function testIPTCParseNoCharset88591b() {
- $iptcData = "Photoshop 3.0\08BIM\4\4\0\0\0\0\0\x09\x1c\x02\x19\x00\x04\xC3\xC3\xC3\xB8";
- $res = IPTC::Parse( $iptcData );
- $this->assertEquals( array( 'ÃÃø' ), $res['Keywords'] );
- }
- /* Same as testIPTCParseNoCharset88591b, but forcing the charset to utf-8.
- * What should happen is the first "\xC3\xC3" should be dropped as invalid,
- * leaving \xC3\xB8, which is ø
- */
- public function testIPTCParseForcedUTFButInvalid() {
- $iptcData = "Photoshop 3.0\08BIM\4\4\0\0\0\0\0\x11\x1c\x02\x19\x00\x04\xC3\xC3\xC3\xB8"
- . "\x1c\x01\x5A\x00\x03\x1B\x25\x47";
- $res = IPTC::Parse( $iptcData );
- $this->assertEquals( array( 'ø' ), $res['Keywords'] );
- }
- public function testIPTCParseNoCharsetUTF8() {
- $iptcData = "Photoshop 3.0\08BIM\4\4\0\0\0\0\0\x07\x1c\x02\x19\x00\x02¼";
- $res = IPTC::Parse( $iptcData );
- $this->assertEquals( array( '¼' ), $res['Keywords'] );
- }
- // Testing something that has 2 values for keyword
- public function testIPTCParseMulti() {
- $iptcData = /* identifier */ "Photoshop 3.0\08BIM\4\4"
- /* length */ . "\0\0\0\0\0\x0D"
- . "\x1c\x02\x19" . "\x00\x01" . "\xBC"
- . "\x1c\x02\x19" . "\x00\x02" . "\xBC\xBD";
- $res = IPTC::Parse( $iptcData );
- $this->assertEquals( array( '¼', '¼½' ), $res['Keywords'] );
- }
- public function testIPTCParseUTF8() {
- // This has the magic "\x1c\x01\x5A\x00\x03\x1B\x25\x47" which marks content as UTF8.
- $iptcData = "Photoshop 3.0\08BIM\4\4\0\0\0\0\0\x0F\x1c\x02\x19\x00\x02¼\x1c\x01\x5A\x00\x03\x1B\x25\x47";
- $res = IPTC::Parse( $iptcData );
- $this->assertEquals( array( '¼' ), $res['Keywords'] );
- }
-
-}
diff --git a/tests/phpunit/includes/media/JpegMetadataExtractorTest.php b/tests/phpunit/includes/media/JpegMetadataExtractorTest.php
deleted file mode 100644
index 41d81190..00000000
--- a/tests/phpunit/includes/media/JpegMetadataExtractorTest.php
+++ /dev/null
@@ -1,94 +0,0 @@
-filePath = __DIR__ . '/../../data/media/';
- }
-
- /**
- * We also use this test to test padding bytes don't
- * screw stuff up
- *
- * @param $file filename
- *
- * @dataProvider dataUtf8Comment
- */
- public function testUtf8Comment( $file ) {
- $res = JpegMetadataExtractor::segmentSplitter( $this->filePath . $file );
- $this->assertEquals( array( 'UTF-8 JPEG Comment — ¼' ), $res['COM'] );
- }
- public function dataUtf8Comment() {
- return array(
- array( 'jpeg-comment-utf.jpg' ),
- array( 'jpeg-padding-even.jpg' ),
- array( 'jpeg-padding-odd.jpg' ),
- );
- }
- /** The file is iso-8859-1, but it should get auto converted */
- public function testIso88591Comment() {
- $res = JpegMetadataExtractor::segmentSplitter( $this->filePath . 'jpeg-comment-iso8859-1.jpg' );
- $this->assertEquals( array( 'ISO-8859-1 JPEG Comment - ¼' ), $res['COM'] );
- }
- /** Comment values that are non-textual (random binary junk) should not be shown.
- * The example test file has a comment with a 0x5 byte in it which is a control character
- * and considered binary junk for our purposes.
- */
- public function testBinaryCommentStripped() {
- $res = JpegMetadataExtractor::segmentSplitter( $this->filePath . 'jpeg-comment-binary.jpg' );
- $this->assertEmpty( $res['COM'] );
- }
- /* Very rarely a file can have multiple comments.
- * Order of comments is based on order inside the file.
- */
- public function testMultipleComment() {
- $res = JpegMetadataExtractor::segmentSplitter( $this->filePath . 'jpeg-comment-multiple.jpg' );
- $this->assertEquals( array( 'foo', 'bar' ), $res['COM'] );
- }
- public function testXMPExtraction() {
- $res = JpegMetadataExtractor::segmentSplitter( $this->filePath . 'jpeg-xmp-psir.jpg' );
- $expected = file_get_contents( $this->filePath . 'jpeg-xmp-psir.xmp' );
- $this->assertEquals( $expected, $res['XMP'] );
- }
- public function testPSIRExtraction() {
- $res = JpegMetadataExtractor::segmentSplitter( $this->filePath . 'jpeg-xmp-psir.jpg' );
- $expected = '50686f746f73686f7020332e30003842494d04040000000000181c02190004746573741c02190003666f6f1c020000020004';
- $this->assertEquals( $expected, bin2hex( $res['PSIR'][0] ) );
- }
- public function testXMPExtractionAltAppId() {
- $res = JpegMetadataExtractor::segmentSplitter( $this->filePath . 'jpeg-xmp-alt.jpg' );
- $expected = file_get_contents( $this->filePath . 'jpeg-xmp-psir.xmp' );
- $this->assertEquals( $expected, $res['XMP'] );
- }
-
-
- public function testIPTCHashComparisionNoHash() {
- $segments = JpegMetadataExtractor::segmentSplitter( $this->filePath . 'jpeg-xmp-psir.jpg' );
- $res = JpegMetadataExtractor::doPSIR( $segments['PSIR'][0] );
-
- $this->assertEquals( 'iptc-no-hash', $res );
- }
- public function testIPTCHashComparisionBadHash() {
- $segments = JpegMetadataExtractor::segmentSplitter( $this->filePath . 'jpeg-iptc-bad-hash.jpg' );
- $res = JpegMetadataExtractor::doPSIR( $segments['PSIR'][0] );
-
- $this->assertEquals( 'iptc-bad-hash', $res );
- }
- public function testIPTCHashComparisionGoodHash() {
- $segments = JpegMetadataExtractor::segmentSplitter( $this->filePath . 'jpeg-iptc-good-hash.jpg' );
- $res = JpegMetadataExtractor::doPSIR( $segments['PSIR'][0] );
-
- $this->assertEquals( 'iptc-good-hash', $res );
- }
- public function testExifByteOrder() {
- $res = JpegMetadataExtractor::segmentSplitter( $this->filePath . 'exif-user-comment.jpg' );
- $expected = 'BE';
- $this->assertEquals( $expected, $res['byteOrder'] );
- }
-}
diff --git a/tests/phpunit/includes/media/JpegTest.php b/tests/phpunit/includes/media/JpegTest.php
deleted file mode 100644
index ea007f90..00000000
--- a/tests/phpunit/includes/media/JpegTest.php
+++ /dev/null
@@ -1,31 +0,0 @@
-filePath = __DIR__ . '/../../data/media/';
- if ( !wfDl( 'exif' ) ) {
- $this->markTestSkipped( "This test needs the exif extension." );
- }
- global $wgShowEXIF;
- $this->show = $wgShowEXIF;
- $wgShowEXIF = true;
- }
- public function tearDown() {
- global $wgShowEXIF;
- $wgShowEXIF = $this->show;
- }
-
- public function testInvalidFile() {
- $jpeg = new JpegHandler;
- $res = $jpeg->getMetadata( null, $this->filePath . 'README' );
- $this->assertEquals( ExifBitmapHandler::BROKEN_FILE, $res );
- }
- public function testJpegMetadataExtraction() {
- $h = new JpegHandler;
- $res = $h->getMetadata( null, $this->filePath . 'test.jpg' );
- $expected = 'a:7:{s:16:"ImageDescription";s:9:"Test file";s:11:"XResolution";s:4:"72/1";s:11:"YResolution";s:4:"72/1";s:14:"ResolutionUnit";i:2;s:16:"YCbCrPositioning";i:1;s:15:"JPEGFileComment";a:1:{i:0;s:17:"Created with GIMP";}s:22:"MEDIAWIKI_EXIF_VERSION";i:2;}';
-
- // Unserialize in case serialization format ever changes.
- $this->assertEquals( unserialize( $expected ), unserialize( $res ) );
- }
-}
diff --git a/tests/phpunit/includes/media/MediaHandlerTest.php b/tests/phpunit/includes/media/MediaHandlerTest.php
deleted file mode 100644
index 99df4f80..00000000
--- a/tests/phpunit/includes/media/MediaHandlerTest.php
+++ /dev/null
@@ -1,50 +0,0 @@
- 50,
- 'height' => 50,
- 'tests' => array(
- 50 => 50,
- 17 => 17,
- 18 => 18 ) ),
- array(
- 'width' => 366,
- 'height' => 300,
- 'tests' => array(
- 50 => 61,
- 17 => 21,
- 18 => 22 ) ),
- array(
- 'width' => 300,
- 'height' => 366,
- 'tests' => array(
- 50 => 41,
- 17 => 14,
- 18 => 15 ) ),
- array(
- 'width' => 100,
- 'height' => 400,
- 'tests' => array(
- 50 => 12,
- 17 => 4,
- 18 => 4 ) ) );
- foreach ( $vals as $row ) {
- $tests = $row['tests'];
- $height = $row['height'];
- $width = $row['width'];
- foreach ( $tests as $max => $expected ) {
- $y = round( $expected * $height / $width );
- $result = MediaHandler::fitBoxWidth( $width, $height, $max );
- $y2 = round( $result * $height / $width );
- $this->assertEquals( $expected,
- $result,
- "($width, $height, $max) wanted: {$expected}x$y, got: {$result}x$y2" );
- }
- }
- }
-}
-
-
diff --git a/tests/phpunit/includes/media/PNGMetadataExtractorTest.php b/tests/phpunit/includes/media/PNGMetadataExtractorTest.php
deleted file mode 100644
index 1b1b2ec3..00000000
--- a/tests/phpunit/includes/media/PNGMetadataExtractorTest.php
+++ /dev/null
@@ -1,141 +0,0 @@
-filePath = __DIR__ . '/../../data/media/';
- }
- /**
- * Tests zTXt tag (compressed textual metadata)
- */
- function testPngNativetZtxt() {
- $meta = PNGMetadataExtractor::getMetadata( $this->filePath .
- 'Png-native-test.png' );
- $expected = "foo bar baz foo foo foo foof foo foo foo foo";
- $this->assertArrayHasKey( 'text', $meta );
- $meta = $meta['text'];
- $this->assertArrayHasKey( 'Make', $meta );
- $this->assertArrayHasKey( 'x-default', $meta['Make'] );
-
- $this->assertEquals( $expected, $meta['Make']['x-default'] );
- }
-
- /**
- * Test tEXt tag (Uncompressed textual metadata)
- */
- function testPngNativeText() {
- $meta = PNGMetadataExtractor::getMetadata( $this->filePath .
- 'Png-native-test.png' );
- $expected = "Some long image desc";
- $this->assertArrayHasKey( 'text', $meta );
- $meta = $meta['text'];
- $this->assertArrayHasKey( 'ImageDescription', $meta );
- $this->assertArrayHasKey( 'x-default', $meta['ImageDescription'] );
- $this->assertArrayHasKey( '_type', $meta['ImageDescription'] );
-
- $this->assertEquals( $expected, $meta['ImageDescription']['x-default'] );
- }
-
- /**
- * tEXt tags must be encoded iso-8859-1 (vs iTXt which are utf-8)
- * Make sure non-ascii characters get converted properly
- */
- function testPngNativeTextNonAscii() {
- $meta = PNGMetadataExtractor::getMetadata( $this->filePath .
- 'Png-native-test.png' );
-
- // Note the Copyright symbol here is a utf-8 one
- // (aka \xC2\xA9) where in the file its iso-8859-1
- // encoded as just \xA9.
- $expected = "© 2010 Bawolff";
-
-
- $this->assertArrayHasKey( 'text', $meta );
- $meta = $meta['text'];
- $this->assertArrayHasKey( 'Copyright', $meta );
- $this->assertArrayHasKey( 'x-default', $meta['Copyright'] );
-
- $this->assertEquals( $expected, $meta['Copyright']['x-default'] );
- }
-
- /**
- * Test extraction of pHYs tags, which can tell what the
- * actual resolution of the image is (aka in dots per meter).
- function testPngPhysTag () {
- $meta = PNGMetadataExtractor::getMetadata( $this->filePath .
- 'Png-native-test.png' );
-
- $this->assertArrayHasKey( 'text', $meta );
- $meta = $meta['text'];
-
- $this->assertEquals( '2835/100', $meta['XResolution'] );
- $this->assertEquals( '2835/100', $meta['YResolution'] );
- $this->assertEquals( 3, $meta['ResolutionUnit'] ); // 3 = cm
- }
-
- /**
- * Given a normal static PNG, check the animation metadata returned.
- */
- function testStaticPngAnimationMetadata() {
- $meta = PNGMetadataExtractor::getMetadata( $this->filePath .
- 'Png-native-test.png' );
-
- $this->assertEquals( 0, $meta['frameCount'] );
- $this->assertEquals( 1, $meta['loopCount'] );
- $this->assertEquals( 0, $meta['duration'] );
- }
-
- /**
- * Given an animated APNG image file
- * check it gets animated metadata right.
- */
- function testApngAnimationMetadata() {
- $meta = PNGMetadataExtractor::getMetadata( $this->filePath .
- 'Animated_PNG_example_bouncing_beach_ball.png' );
-
- $this->assertEquals( 20, $meta['frameCount'] );
- // Note loop count of 0 = infinity
- $this->assertEquals( 0, $meta['loopCount'] );
- $this->assertEquals( 1.5, $meta['duration'], '', 0.00001 );
- }
-
- function testPngBitDepth8() {
- $meta = PNGMetadataExtractor::getMetadata( $this->filePath .
- 'Png-native-test.png' );
-
- $this->assertEquals( 8, $meta['bitDepth'] );
- }
- function testPngBitDepth1() {
- $meta = PNGMetadataExtractor::getMetadata( $this->filePath .
- '1bit-png.png' );
- $this->assertEquals( 1, $meta['bitDepth'] );
- }
-
-
- function testPngIndexColour() {
- $meta = PNGMetadataExtractor::getMetadata( $this->filePath .
- 'Png-native-test.png' );
-
- $this->assertEquals( 'index-coloured', $meta['colorType'] );
- }
- function testPngRgbColour() {
- $meta = PNGMetadataExtractor::getMetadata( $this->filePath .
- 'rgb-png.png' );
- $this->assertEquals( 'truecolour-alpha', $meta['colorType'] );
- }
- function testPngRgbNoAlphaColour() {
- $meta = PNGMetadataExtractor::getMetadata( $this->filePath .
- 'rgb-na-png.png' );
- $this->assertEquals( 'truecolour', $meta['colorType'] );
- }
- function testPngGreyscaleColour() {
- $meta = PNGMetadataExtractor::getMetadata( $this->filePath .
- 'greyscale-png.png' );
- $this->assertEquals( 'greyscale-alpha', $meta['colorType'] );
- }
- function testPngGreyscaleNoAlphaColour() {
- $meta = PNGMetadataExtractor::getMetadata( $this->filePath .
- 'greyscale-na-png.png' );
- $this->assertEquals( 'greyscale', $meta['colorType'] );
- }
-
-}
diff --git a/tests/phpunit/includes/media/PNGTest.php b/tests/phpunit/includes/media/PNGTest.php
deleted file mode 100644
index fe73c9c7..00000000
--- a/tests/phpunit/includes/media/PNGTest.php
+++ /dev/null
@@ -1,100 +0,0 @@
-filePath = __DIR__ . '/../../data/media';
- $this->backend = new FSFileBackend( array(
- 'name' => 'localtesting',
- 'lockManager' => 'nullLockManager',
- 'containerPaths' => array( 'data' => $this->filePath )
- ) );
- $this->repo = new FSRepo( array(
- 'name' => 'temp',
- 'url' => 'http://localhost/thumbtest',
- 'backend' => $this->backend
- ) );
- $this->handler = new PNGHandler();
- }
-
- public function testInvalidFile() {
- $res = $this->handler->getMetadata( null, $this->filePath . '/README' );
- $this->assertEquals( PNGHandler::BROKEN_FILE, $res );
- }
- /**
- * @param $filename String basename of the file to check
- * @param $expected boolean Expected result.
- * @dataProvider dataIsAnimated
- */
- public function testIsAnimanted( $filename, $expected ) {
- $file = $this->dataFile( $filename, 'image/png' );
- $actual = $this->handler->isAnimatedImage( $file );
- $this->assertEquals( $expected, $actual );
- }
- public function dataIsAnimated() {
- return array(
- array( 'Animated_PNG_example_bouncing_beach_ball.png', true ),
- array( '1bit-png.png', false ),
- );
- }
-
- /**
- * @param $filename String
- * @param $expected Integer Total image area
- * @dataProvider dataGetImageArea
- */
- public function testGetImageArea( $filename, $expected ) {
- $file = $this->dataFile($filename, 'image/png' );
- $actual = $this->handler->getImageArea( $file, $file->getWidth(), $file->getHeight() );
- $this->assertEquals( $expected, $actual );
- }
- public function dataGetImageArea() {
- return array(
- array( '1bit-png.png', 2500 ),
- array( 'greyscale-png.png', 2500 ),
- array( 'Png-native-test.png', 126000 ),
- array( 'Animated_PNG_example_bouncing_beach_ball.png', 10000 ),
- );
- }
-
- /**
- * @param $metadata String Serialized metadata
- * @param $expected Integer One of the class constants of PNGHandler
- * @dataProvider dataIsMetadataValid
- */
- public function testIsMetadataValid( $metadata, $expected ) {
- $actual = $this->handler->isMetadataValid( null, $metadata );
- $this->assertEquals( $expected, $actual );
- }
- public function dataIsMetadataValid() {
- return array(
- array( PNGHandler::BROKEN_FILE, PNGHandler::METADATA_GOOD ),
- array( '', PNGHandler::METADATA_BAD ),
- array( null, PNGHandler::METADATA_BAD ),
- array( 'Something invalid!', PNGHandler::METADATA_BAD ),
- array( 'a:6:{s:10:"frameCount";i:0;s:9:"loopCount";i:1;s:8:"duration";d:0;s:8:"bitDepth";i:8;s:9:"colorType";s:10:"truecolour";s:8:"metadata";a:1:{s:15:"_MW_PNG_VERSION";i:1;}}', PNGHandler::METADATA_GOOD ),
- );
- }
-
- /**
- * @param $filename String
- * @param $expected String Serialized array
- * @dataProvider dataGetMetadata
- */
- public function testGetMetadata( $filename, $expected ) {
- $file = $this->dataFile( $filename, 'image/png' );
- $actual = $this->handler->getMetadata( $file, "$this->filePath/$filename" );
-// $this->assertEquals( unserialize( $expected ), unserialize( $actual ) );
- $this->assertEquals( ( $expected ), ( $actual ) );
- }
- public function dataGetMetadata() {
- return array(
- array( 'rgb-na-png.png', 'a:6:{s:10:"frameCount";i:0;s:9:"loopCount";i:1;s:8:"duration";d:0;s:8:"bitDepth";i:8;s:9:"colorType";s:10:"truecolour";s:8:"metadata";a:1:{s:15:"_MW_PNG_VERSION";i:1;}}' ),
- array( 'xmp.png', 'a:6:{s:10:"frameCount";i:0;s:9:"loopCount";i:1;s:8:"duration";d:0;s:8:"bitDepth";i:1;s:9:"colorType";s:14:"index-coloured";s:8:"metadata";a:2:{s:12:"SerialNumber";s:9:"123456789";s:15:"_MW_PNG_VERSION";i:1;}}' ),
- );
- }
-
- private function dataFile( $name, $type ) {
- return new UnregisteredLocalFile( false, $this->repo,
- "mwstore://localtesting/data/$name", $type );
- }
-}
diff --git a/tests/phpunit/includes/media/SVGMetadataExtractorTest.php b/tests/phpunit/includes/media/SVGMetadataExtractorTest.php
deleted file mode 100644
index 2116554e..00000000
--- a/tests/phpunit/includes/media/SVGMetadataExtractorTest.php
+++ /dev/null
@@ -1,108 +0,0 @@
-assertMetadata( $infile, $expected );
- }
-
- /**
- * @dataProvider providerSvgFilesWithXMLMetadata
- */
- function testGetXMLMetadata( $infile, $expected ) {
- $r = new XMLReader();
- if( !method_exists( $r, 'readInnerXML' ) ) {
- $this->markTestSkipped( 'XMLReader::readInnerXML() does not exist (libxml >2.6.20 needed).' );
- return;
- }
- $this->assertMetadata( $infile, $expected );
- }
-
- function assertMetadata( $infile, $expected ) {
- try {
- $data = SVGMetadataExtractor::getMetadata( $infile );
- $this->assertEquals( $expected, $data, 'SVG metadata extraction test' );
- } catch ( MWException $e ) {
- if ( $expected === false ) {
- $this->assertTrue( true, 'SVG metadata extracted test (expected failure)' );
- } else {
- throw $e;
- }
- }
- }
-
- function providerSvgFiles() {
- $base = __DIR__ . '/../../data/media';
- return array(
- array(
- "$base/Wikimedia-logo.svg",
- array(
- 'width' => 1024,
- 'height' => 1024,
- 'originalWidth' => '1024',
- 'originalHeight' => '1024',
- )
- ),
- array(
- "$base/QA_icon.svg",
- array(
- 'width' => 60,
- 'height' => 60,
- 'originalWidth' => '60',
- 'originalHeight' => '60',
- )
- ),
- array(
- "$base/Gtk-media-play-ltr.svg",
- array(
- 'width' => 60,
- 'height' => 60,
- 'originalWidth' => '60.0000000',
- 'originalHeight' => '60.0000000',
- )
- ),
- array(
- "$base/Toll_Texas_1.svg",
- // This file triggered bug 31719, needs entity expansion in the xmlns checks
- array(
- 'width' => 385,
- 'height' => 385,
- 'originalWidth' => '385',
- 'originalHeight' => '385.0004883',
- )
- )
- );
- }
-
- function providerSvgFilesWithXMLMetadata() {
- $base = __DIR__ . '/../../data/media';
- $metadata =
- '
-
- image/svg+xml
-
-
- ';
- $metadata = str_replace( "\r", '', $metadata ); // Windows compat
- return array(
- array(
- "$base/US_states_by_total_state_tax_revenue.svg",
- array(
- 'height' => 593,
- 'metadata' => $metadata,
- 'width' => 959,
- 'originalWidth' => '958.69',
- 'originalHeight' => '592.78998',
- )
- ),
- );
- }
-}
-
diff --git a/tests/phpunit/includes/media/TiffTest.php b/tests/phpunit/includes/media/TiffTest.php
deleted file mode 100644
index 4c79f66c..00000000
--- a/tests/phpunit/includes/media/TiffTest.php
+++ /dev/null
@@ -1,35 +0,0 @@
-showExif = $wgShowEXIF;
- $wgShowEXIF = true;
- $this->filePath = __DIR__ . '/../../data/media/';
- $this->handler = new TiffHandler;
- }
-
- public function tearDown() {
- global $wgShowEXIF;
- $wgShowEXIF = $this->showExif;
- }
-
- public function testInvalidFile() {
- if ( !wfDl( 'exif' ) ) {
- $this->markTestIncomplete( "This test needs the exif extension." );
- }
- $res = $this->handler->getMetadata( null, $this->filePath . 'README' );
- $this->assertEquals( ExifBitmapHandler::BROKEN_FILE, $res );
- }
-
- public function testTiffMetadataExtraction() {
- if ( !wfDl( 'exif' ) ) {
- $this->markTestIncomplete( "This test needs the exif extension." );
- }
- $res = $this->handler->getMetadata( null, $this->filePath . 'test.tiff' );
- $expected = 'a:16:{s:10:"ImageWidth";i:20;s:11:"ImageLength";i:20;s:13:"BitsPerSample";a:3:{i:0;i:8;i:1;i:8;i:2;i:8;}s:11:"Compression";i:5;s:25:"PhotometricInterpretation";i:2;s:16:"ImageDescription";s:17:"Created with GIMP";s:12:"StripOffsets";i:8;s:11:"Orientation";i:1;s:15:"SamplesPerPixel";i:3;s:12:"RowsPerStrip";i:64;s:15:"StripByteCounts";i:238;s:11:"XResolution";s:19:"1207959552/16777216";s:11:"YResolution";s:19:"1207959552/16777216";s:19:"PlanarConfiguration";i:1;s:14:"ResolutionUnit";i:2;s:22:"MEDIAWIKI_EXIF_VERSION";i:2;}';
- // Re-unserialize in case there are subtle differences between how versions
- // of php serialize stuff.
- $this->assertEquals( unserialize( $expected ), unserialize( $res ) );
- }
-}
diff --git a/tests/phpunit/includes/media/XMPTest.php b/tests/phpunit/includes/media/XMPTest.php
deleted file mode 100644
index 8198d3b0..00000000
--- a/tests/phpunit/includes/media/XMPTest.php
+++ /dev/null
@@ -1,158 +0,0 @@
-markTestSkipped( 'Requires libxml to do XMP parsing' );
- }
- }
-
- /**
- * Put XMP in, compare what comes out...
- *
- * @param $xmp String the actual xml data.
- * @param $expected Array expected result of parsing the xmp.
- * @param $info String Short sentence on what's being tested.
- *
- * @dataProvider dataXMPParse
- */
- public function testXMPParse( $xmp, $expected, $info ) {
- if ( !is_string( $xmp ) || !is_array( $expected ) ) {
- throw new Exception( "Invalid data provided to " . __METHOD__ );
- }
- $reader = new XMPReader;
- $reader->parse( $xmp );
- $this->assertEquals( $expected, $reader->getResults(), $info, 0.0000000001 );
- }
-
- public function dataXMPParse() {
- $xmpPath = __DIR__ . '/../../data/xmp/' ;
- $data = array();
-
- // $xmpFiles format: array of arrays with first arg file base name,
- // with the actual file having .xmp on the end for the xmp
- // and .result.php on the end for a php file containing the result
- // array. Second argument is some info on what's being tested.
- $xmpFiles = array(
- array( '1', 'parseType=Resource test' ),
- array( '2', 'Structure with mixed attribute and element props' ),
- array( '3', 'Extra qualifiers (that should be ignored)' ),
- array( '3-invalid', 'Test ignoring qualifiers that look like normal props' ),
- array( '4', 'Flash as qualifier' ),
- array( '5', 'Flash as qualifier 2' ),
- array( '6', 'Multiple rdf:Description' ),
- array( '7', 'Generic test of several property types' ),
- array( 'flash', 'Test of Flash property' ),
- array( 'invalid-child-not-struct', 'Test child props not in struct or ignored' ),
- array( 'no-recognized-props', 'Test namespace and no recognized props' ),
- array( 'no-namespace', 'Test non-namespaced attributes are ignored' ),
- array( 'bag-for-seq', "Allow bag's instead of seq's. (bug 27105)" ),
- array( 'utf16BE', 'UTF-16BE encoding' ),
- array( 'utf16LE', 'UTF-16LE encoding' ),
- array( 'utf32BE', 'UTF-32BE encoding' ),
- array( 'utf32LE', 'UTF-32LE encoding' ),
- array( 'xmpExt', 'Extended XMP missing second part' ),
- array( 'gps', 'Handling of exif GPS parameters in XMP' ),
- );
- foreach( $xmpFiles as $file ) {
- $xmp = file_get_contents( $xmpPath . $file[0] . '.xmp' );
- // I'm not sure if this is the best way to handle getting the
- // result array, but it seems kind of big to put directly in the test
- // file.
- $result = null;
- include( $xmpPath . $file[0] . '.result.php' );
- $data[] = array( $xmp, $result, '[' . $file[0] . '.xmp] ' . $file[1] );
- }
- return $data;
- }
-
- /** Test ExtendedXMP block support. (Used when the XMP has to be split
- * over multiple jpeg segments, due to 64k size limit on jpeg segments.
- *
- * @todo This is based on what the standard says. Need to find a real
- * world example file to double check the support for this is right.
- */
- function testExtendedXMP() {
- $xmpPath = __DIR__ . '/../../data/xmp/';
- $standardXMP = file_get_contents( $xmpPath . 'xmpExt.xmp' );
- $extendedXMP = file_get_contents( $xmpPath . 'xmpExt2.xmp' );
-
- $md5sum = '28C74E0AC2D796886759006FBE2E57B7'; // of xmpExt2.xmp
- $length = pack( 'N', strlen( $extendedXMP ) );
- $offset = pack( 'N', 0 );
- $extendedPacket = $md5sum . $length . $offset . $extendedXMP;
-
- $reader = new XMPReader();
- $reader->parse( $standardXMP );
- $reader->parseExtended( $extendedPacket );
- $actual = $reader->getResults();
-
- $expected = array( 'xmp-exif' =>
- array(
- 'DigitalZoomRatio' => '0/10',
- 'Flash' => 9,
- 'FNumber' => '2/10',
- )
- );
-
- $this->assertEquals( $expected, $actual );
- }
-
- /**
- * This test has an extended XMP block with a wrong guid (md5sum)
- * and thus should only return the StandardXMP, not the ExtendedXMP.
- */
- function testExtendedXMPWithWrongGUID() {
- $xmpPath = __DIR__ . '/../../data/xmp/';
- $standardXMP = file_get_contents( $xmpPath . 'xmpExt.xmp' );
- $extendedXMP = file_get_contents( $xmpPath . 'xmpExt2.xmp' );
-
- $md5sum = '28C74E0AC2D796886759006FBE2E57B9'; // Note last digit.
- $length = pack( 'N', strlen( $extendedXMP ) );
- $offset = pack( 'N', 0 );
- $extendedPacket = $md5sum . $length . $offset . $extendedXMP;
-
- $reader = new XMPReader();
- $reader->parse( $standardXMP );
- $reader->parseExtended( $extendedPacket );
- $actual = $reader->getResults();
-
- $expected = array( 'xmp-exif' =>
- array(
- 'DigitalZoomRatio' => '0/10',
- 'Flash' => 9,
- )
- );
-
- $this->assertEquals( $expected, $actual );
- }
- /**
- * Have a high offset to simulate a missing packet,
- * which should cause it to ignore the ExtendedXMP packet.
- */
- function testExtendedXMPMissingPacket() {
- $xmpPath = __DIR__ . '/../../data/xmp/';
- $standardXMP = file_get_contents( $xmpPath . 'xmpExt.xmp' );
- $extendedXMP = file_get_contents( $xmpPath . 'xmpExt2.xmp' );
-
- $md5sum = '28C74E0AC2D796886759006FBE2E57B7'; // of xmpExt2.xmp
- $length = pack( 'N', strlen( $extendedXMP ) );
- $offset = pack( 'N', 2048 );
- $extendedPacket = $md5sum . $length . $offset . $extendedXMP;
-
- $reader = new XMPReader();
- $reader->parse( $standardXMP );
- $reader->parseExtended( $extendedPacket );
- $actual = $reader->getResults();
-
- $expected = array( 'xmp-exif' =>
- array(
- 'DigitalZoomRatio' => '0/10',
- 'Flash' => 9,
- )
- );
-
- $this->assertEquals( $expected, $actual );
- }
-
-}
diff --git a/tests/phpunit/includes/media/XMPValidateTest.php b/tests/phpunit/includes/media/XMPValidateTest.php
deleted file mode 100644
index e2bb8d8d..00000000
--- a/tests/phpunit/includes/media/XMPValidateTest.php
+++ /dev/null
@@ -1,47 +0,0 @@
-assertEquals( $expected, $value );
- }
-
- function providerDate() {
- /* For reference valid date formats are:
- * YYYY
- * YYYY-MM
- * YYYY-MM-DD
- * YYYY-MM-DDThh:mmTZD
- * YYYY-MM-DDThh:mm:ssTZD
- * YYYY-MM-DDThh:mm:ss.sTZD
- * (Time zone is optional)
- */
- return array(
- array( '1992', '1992' ),
- array( '1992-04', '1992:04' ),
- array( '1992-02-01', '1992:02:01' ),
- array( '2011-09-29', '2011:09:29' ),
- array( '1982-12-15T20:12', '1982:12:15 20:12' ),
- array( '1982-12-15T20:12Z', '1982:12:15 20:12' ),
- array( '1982-12-15T20:12+02:30', '1982:12:15 22:42' ),
- array( '1982-12-15T01:12-02:30', '1982:12:14 22:42' ),
- array( '1982-12-15T20:12:11', '1982:12:15 20:12:11' ),
- array( '1982-12-15T20:12:11Z', '1982:12:15 20:12:11' ),
- array( '1982-12-15T20:12:11+01:10', '1982:12:15 21:22:11' ),
- array( '2045-12-15T20:12:11', '2045:12:15 20:12:11' ),
- array( '1867-06-01T15:00:00', '1867:06:01 15:00:00' ),
- /* some invalid ones */
- array( '2001--12', null ),
- array( '2001-5-12', null ),
- array( '2001-5-12TZ', null ),
- array( '2001-05-12T15', null ),
- array( '2001-12T15:13', null ),
- );
-
- }
-
-}
diff --git a/tests/phpunit/includes/mobile/DeviceDetectionTest.php b/tests/phpunit/includes/mobile/DeviceDetectionTest.php
deleted file mode 100644
index 0e156532..00000000
--- a/tests/phpunit/includes/mobile/DeviceDetectionTest.php
+++ /dev/null
@@ -1,40 +0,0 @@
-assertEquals( $format, $detector->detectFormatName( $userAgent ) );
- }
-
- public function provideTestFormatName() {
- return array(
- array( 'android', 'Mozilla/5.0 (Linux; U; Android 2.1; en-us; Nexus One Build/ERD62) AppleWebKit/530.17 (KHTML, like Gecko) Version/4.0 Mobile Safari/530.17' ),
- array( 'iphone2', 'Mozilla/5.0 (ipod: U;CPU iPhone OS 2_2 like Mac OS X: es_es) AppleWebKit/525.18.1 (KHTML, like Gecko) Version/3.0 Mobile/3B48b Safari/419.3' ),
- array( 'iphone', 'Mozilla/5.0 (iPhone; U; CPU like Mac OS X; en) AppleWebKit/420.1 (KHTML, like Gecko) Version/3.0 Mobile/3B48b Safari/419.3' ),
- array( 'nokia', 'Mozilla/5.0 (SymbianOS/9.1; U; [en]; SymbianOS/91 Series60/3.0) AppleWebKit/413 (KHTML, like Gecko) Safari/413' ),
- array( 'palm_pre', 'Mozilla/5.0 (webOS/1.0; U; en-US) AppleWebKit/525.27.1 (KHTML, like Gecko) Version/1.0 Safari/525.27.1 Pre/1.0' ),
- array( 'wii', 'Opera/9.00 (Nintendo Wii; U; ; 1309-9; en)' ),
- array( 'operamini', 'Opera/9.50 (J2ME/MIDP; Opera Mini/4.0.10031/298; U; en)' ),
- array( 'operamobile', 'Opera/9.51 Beta (Microsoft Windows; PPC; Opera Mobi/1718; U; en)' ),
- array( 'kindle', 'Mozilla/4.0 (compatible; Linux 2.6.10) NetFront/3.3 Kindle/1.0 (screen 600x800)' ),
- array( 'kindle2', 'Mozilla/4.0 (compatible; Linux 2.6.22) NetFront/3.4 Kindle/2.0 (screen 824x1200; rotate)' ),
- array( 'capable', 'Mozilla/5.0 (X11; Linux i686; rv:2.0.1) Gecko/20100101 Firefox/4.0.1' ),
- array( 'netfront', 'Mozilla/4.08 (Windows; Mobile Content Viewer/1.0) NetFront/3.2' ),
- array( 'wap2', 'SonyEricssonK608i/R2L/SN356841000828910 Browser/SEMC-Browser/4.2 Profile/MIDP-2.0 Configuration/CLDC-1.1' ),
- array( 'wap2', 'NokiaN73-2/3.0-630.0.2 Series60/3.0 Profile/MIDP-2.0 Configuration/CLDC-1.1' ),
- array( 'psp', 'Mozilla/4.0 (PSP (PlayStation Portable); 2.00)' ),
- array( 'ps3', 'Mozilla/5.0 (PLAYSTATION 3; 1.00)' ),
- array( 'ie', 'Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; Trident/5.0)' ),
- array( 'ie', 'Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.0)' ),
- array( 'blackberry', 'BlackBerry9300/5.0.0.716 Profile/MIDP-2.1 Configuration/CLDC-1.1 VendorID/133' ),
- array( 'blackberry-lt5', 'BlackBerry7250/4.0.0 Profile/MIDP-2.0 Configuration/CLDC-1.1' ),
- );
- }
-}
diff --git a/tests/phpunit/includes/normal/CleanUpTest.php b/tests/phpunit/includes/normal/CleanUpTest.php
deleted file mode 100644
index d5ad18d8..00000000
--- a/tests/phpunit/includes/normal/CleanUpTest.php
+++ /dev/null
@@ -1,382 +0,0 @@
-
- * http://www.mediawiki.org/
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- * http://www.gnu.org/copyleft/gpl.html
- *
- * @file
- */
-
-/**
- * Additional tests for UtfNormal::cleanUp() function, inclusion
- * regression checks for known problems.
- * Requires PHPUnit.
- *
- * @ingroup UtfNormal
- */
-class CleanUpTest extends MediaWikiTestCase {
- /** @todo document */
- function testAscii() {
- $text = 'This is plain ASCII text.';
- $this->assertEquals( $text, UtfNormal::cleanUp( $text ) );
- }
-
- /** @todo document */
- function testNull() {
- $text = "a \x00 null";
- $expect = "a \xef\xbf\xbd null";
- $this->assertEquals(
- bin2hex( $expect ),
- bin2hex( UtfNormal::cleanUp( $text ) ) );
- }
-
- /** @todo document */
- function testLatin() {
- $text = "L'\xc3\xa9cole";
- $this->assertEquals( $text, UtfNormal::cleanUp( $text ) );
- }
-
- /** @todo document */
- function testLatinNormal() {
- $text = "L'e\xcc\x81cole";
- $expect = "L'\xc3\xa9cole";
- $this->assertEquals( $expect, UtfNormal::cleanUp( $text ) );
- }
-
- /**
- * This test is *very* expensive!
- * @todo document
- */
- function XtestAllChars() {
- $rep = UTF8_REPLACEMENT;
- 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 );
- $this->assertEquals(
- bin2hex( $comp ),
- bin2hex( $clean ),
- "U+$x should be decomposed" );
- } else {
- $this->assertEquals(
- bin2hex( $char ),
- bin2hex( $clean ),
- "U+$x should be intact" );
- }
- } else {
- $this->assertEquals( bin2hex( $rep ), bin2hex( $clean ), $x );
- }
- }
- }
-
- /** @todo document */
- function testAllBytes() {
- $this->doTestBytes( '', '' );
- $this->doTestBytes( 'x', '' );
- $this->doTestBytes( '', 'x' );
- $this->doTestBytes( 'x', 'x' );
- }
-
- /** @todo document */
- function doTestBytes( $head, $tail ) {
- 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) ) {
- $this->assertEquals(
- bin2hex( $char ),
- bin2hex( $clean ),
- "ASCII byte $x should be intact" );
- 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;
- }
- }
- }
-
- /** @todo document */
- function testDoubleBytes() {
- $this->doTestDoubleBytes( '', '' );
- $this->doTestDoubleBytes( 'x', '' );
- $this->doTestDoubleBytes( '', 'x' );
- $this->doTestDoubleBytes( 'x', 'x' );
- }
-
- /**
- * @todo document
- */
- function doTestDoubleBytes( $head, $tail ) {
- 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 );
- $this->assertEquals(
- bin2hex( $norm ),
- bin2hex( $clean ),
- "Pair $x should be intact" );
- 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;
- } else {
- $norm = $head . UTF8_REPLACEMENT . $tail;
- $this->assertEquals(
- bin2hex( $norm ),
- bin2hex( $clean ),
- "Forbidden pair $x should be rejected" );
- if( $norm != $clean ) return;
- }
- }
- }
- }
-
- /** @todo document */
- function testTripleBytes() {
- $this->doTestTripleBytes( '', '' );
- $this->doTestTripleBytes( 'x', '' );
- $this->doTestTripleBytes( '', 'x' );
- $this->doTestTripleBytes( 'x', 'x' );
- }
-
- /** @todo document */
- function doTestTripleBytes( $head, $tail ) {
- 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++ ) {
- $char = $head . chr( $first ) . chr( $second ) . chr( $third ) . $tail;
- $clean = UtfNormal::cleanUp( $char );
- $x = sprintf( "%02X,%02X,%02X", $first, $second, $third );
- if( $first >= 0xe0 &&
- $first < 0xf0 &&
- $second < 0xc0 &&
- $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 ) {
- $this->assertEquals(
- bin2hex( $head . UTF8_REPLACEMENT . $tail ),
- bin2hex( $clean ),
- "Surrogate triplet $x should be rejected" );
- } else {
- $this->assertEquals(
- bin2hex( UtfNormal::NFC( $char ) ),
- bin2hex( $clean ),
- "Triplet $x should be intact" );
- }
- } 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 ) {
- $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 ) ) ) {
- # 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 ) {
- $this->assertEquals(
- bin2hex( $head . UTF8_REPLACEMENT . $tail ),
- bin2hex( $clean ),
- "Forbidden triplet $x should be rejected" );
- } else {
- $this->assertEquals(
- bin2hex( $head . UTF8_REPLACEMENT . UTF8_REPLACEMENT . $tail ),
- bin2hex( $clean ),
- "Forbidden triplet $x should be rejected" );
- }
- }
- }
- }
- }
-
- /** @todo document */
- function testChunkRegression() {
- # Check for regression against a chunking bug
- $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";
-
- $this->assertEquals(
- bin2hex( $expect ),
- bin2hex( UtfNormal::cleanUp( $text ) ) );
- }
-
- /** @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";
-
- $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";
-
- $this->assertEquals(
- bin2hex( $expect ),
- bin2hex( UtfNormal::cleanUp( $text ) ) );
- }
-
- /** @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
- $expect = "\x67" .
- "\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
- $expect = "\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";
- $expect = "\xef\xbf\xbd" .
- "\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
- $expect = "\xef\xbf\xbd";
- $this->assertEquals(
- bin2hex( $expect ),
- bin2hex( UtfNormal::cleanUp( $text ) ) );
- }
-
- /** @todo document */
- function testHangulRegression() {
- $text = "\xed\x9c\xaf" . # Hangul char
- "\xe1\x87\x81"; # followed by another final jamo
- $expect = $text; # Should *not* change.
- $this->assertEquals(
- bin2hex( $expect ),
- bin2hex( UtfNormal::cleanUp( $text ) ) );
- }
-}
diff --git a/tests/phpunit/includes/parser/MagicVariableTest.php b/tests/phpunit/includes/parser/MagicVariableTest.php
deleted file mode 100644
index 31645313..00000000
--- a/tests/phpunit/includes/parser/MagicVariableTest.php
+++ /dev/null
@@ -1,201 +0,0 @@
-testParser = new Parser();
- $this->testParser->Options( new ParserOptions() );
-
- # initialize parser output
- $this->testParser->clearState();
-
- # Needs a title to do magic word stuff
- $title = Title::newFromText( 'Tests' );
- $title->mRedirect = false; # Else it needs a db connection just to check if it's a redirect (when deciding the page language)
-
- $this->testParser->setTitle( $title );
- }
-
- /** destroy parser (TODO: is it really neded?)*/
- function tearDown() {
- unset( $this->testParser );
- }
-
- ############### TESTS #############################################
- # @todo FIXME:
- # - those got copy pasted, we can probably make them cleaner
- # - tests are lacking useful messages
-
- # day
-
- /** @dataProvider MediaWikiProvide::Days */
- 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 );
- }
-
- # month
-
- /** @dataProvider MediaWikiProvide::Months */
- 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 );
- }
-
-
- # revision day
-
- /** @dataProvider MediaWikiProvide::Days */
- function testRevisiondayIsUnPadded( $day ) {
- $this->assertUnPadded( 'revisionday', $day );
- }
- /** @dataProvider MediaWikiProvide::Days */
- function testRevisiondaytwoIsZeroPadded( $day ) {
- $this->assertZeroPadded( 'revisionday2', $day );
- }
-
- # revision month
-
- /** @dataProvider MediaWikiProvide::Months */
- function testRevisionmonthIsZeroPadded( $month ) {
- $this->assertZeroPadded( 'revisionmonth', $month );
- }
- /** @dataProvider MediaWikiProvide::Months */
- function testRevisionmonthoneIsUnPadded( $month ) {
- $this->assertUnPadded( 'revisionmonth1', $month );
- }
-
- /**
- * Rough tests for {{SERVERNAME}} magic word
- * Bug 31176
- */
- function testServernameFromDifferentProtocols() {
- global $wgServer;
- $saved_wgServer= $wgServer;
-
- $wgServer = 'http://localhost/';
- $this->assertMagic( 'localhost', 'servername' );
- $wgServer = 'https://localhost/';
- $this->assertMagic( 'localhost', 'servername' );
- $wgServer = '//localhost/'; # bug 31176
- $this->assertMagic( 'localhost', 'servername' );
-
- $wgServer = $saved_wgServer;
- }
-
- ############### HELPERS ############################################
-
- /** assertion helper expecting a magic output which is zero padded */
- PUBLIC function assertZeroPadded( $magic, $value ) {
- $this->assertMagicPadding( $magic, $value, '%02d' );
- }
-
- /** assertion helper expecting a magic output which is unpadded */
- PUBLIC function assertUnPadded( $magic, $value ) {
- $this->assertMagicPadding( $magic, $value, '%d' );
- }
-
- /**
- * Main assertion helper for magic variables padding
- * @param $magic string Magic variable name
- * @param $value mixed Month or day
- * @param $format string sprintf format for $value
- */
- 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; }
-
- $this->setParserTS(
- sprintf( '2010%02d%02d123456', $month, $value )
- );
-
- # please keep the following commented line of code. It helps debugging.
- //print "\nDEBUG (value $value):" . sprintf( '2010%02d%02d123456', $value, $value ) . "\n";
-
- # format expectation and test it
- $expected = sprintf( $format, $value );
- $this->assertMagic( $expected, $magic );
- }
-
- /** helper to set the parser timestamp and revision timestamp */
- private function setParserTS( $ts ) {
- $this->testParser->Options()->setTimestamp( $ts );
- $this->testParser->mRevisionTimestamp = $ts;
- }
-
- /**
- * Assertion helper to test a magic variable output
- */
- private function assertMagic( $expected, $magic ) {
- if( in_array( $magic, $this->expectedAsInteger ) ) {
- $expected = (int) $expected;
- }
-
- # Generate a message for the assertion
- $msg = sprintf( "Magic %s should be <%s:%s>",
- $magic,
- $expected,
- gettype( $expected )
- );
-
- $this->assertSame(
- $expected,
- $this->testParser->getVariableValue( $magic ),
- $msg
- );
- }
-}
diff --git a/tests/phpunit/includes/parser/MediaWikiParserTest.php b/tests/phpunit/includes/parser/MediaWikiParserTest.php
deleted file mode 100644
index 6a6fded1..00000000
--- a/tests/phpunit/includes/parser/MediaWikiParserTest.php
+++ /dev/null
@@ -1,36 +0,0 @@
- "\\'", '\\' => '\\\\' ) ) . "'; } " );
-
- $parserTester = new $className( $testsName );
- $suite->addTestSuite( new ReflectionClass ( $parserTester ) );
- }
-
-
- return $suite;
- }
-}
diff --git a/tests/phpunit/includes/parser/NewParserTest.php b/tests/phpunit/includes/parser/NewParserTest.php
deleted file mode 100644
index 69a96e66..00000000
--- a/tests/phpunit/includes/parser/NewParserTest.php
+++ /dev/null
@@ -1,895 +0,0 @@
-getCliArg( 'regex=' ) ) {
- $this->regex = $this->getCliArg( 'regex=' );
- } else {
- # Matches anything
- $this->regex = '';
- }
-
- $this->keepUploads = $this->getCliArg( 'keep-uploads' );
-
- $tmpGlobals = array();
-
- $tmpGlobals['wgScript'] = '/index.php';
- $tmpGlobals['wgScriptPath'] = '/';
- $tmpGlobals['wgArticlePath'] = '/wiki/$1';
- $tmpGlobals['wgStyleSheetPath'] = '/skins';
- $tmpGlobals['wgStylePath'] = '/skins';
- $tmpGlobals['wgThumbnailScriptPath'] = false;
- $tmpGlobals['wgLocalFileRepo'] = array(
- 'class' => 'LocalRepo',
- 'name' => 'local',
- 'url' => 'http://example.com/images',
- 'hashLevels' => 2,
- 'transformVia404' => false,
- 'backend' => 'local-backend'
- );
- $tmpGlobals['wgForeignFileRepos'] = array();
- $tmpGlobals['wgEnableParserCache'] = false;
- $tmpGlobals['wgHooks'] = $wgHooks;
- $tmpGlobals['wgDeferredUpdateList'] = array();
- $tmpGlobals['wgMemc'] = wfGetMainCache();
- $tmpGlobals['messageMemc'] = wfGetMessageCacheStorage();
- $tmpGlobals['parserMemc'] = wfGetParserCacheStorage();
-
- // $tmpGlobals['wgContLang'] = new StubContLang;
- $tmpGlobals['wgUser'] = new User;
- $context = new RequestContext();
- $tmpGlobals['wgLang'] = $context->getLanguage();
- $tmpGlobals['wgOut'] = $context->getOutput();
- $tmpGlobals['wgParser'] = new StubObject( 'wgParser', $GLOBALS['wgParserConf']['class'], array( $GLOBALS['wgParserConf'] ) );
- $tmpGlobals['wgRequest'] = $context->getRequest();
-
- if ( $GLOBALS['wgStyleDirectory'] === false ) {
- $tmpGlobals['wgStyleDirectory'] = "$IP/skins";
- }
-
-
- foreach ( $tmpGlobals as $var => $val ) {
- if ( array_key_exists( $var, $GLOBALS ) ) {
- $this->savedInitialGlobals[$var] = $GLOBALS[$var];
- }
-
- $GLOBALS[$var] = $val;
- }
-
- $this->savedWeirdGlobals['mw_namespace_protection'] = $wgNamespaceProtection[NS_MEDIAWIKI];
- $this->savedWeirdGlobals['image_alias'] = $wgNamespaceAliases['Image'];
- $this->savedWeirdGlobals['image_talk_alias'] = $wgNamespaceAliases['Image_talk'];
-
- $wgNamespaceProtection[NS_MEDIAWIKI] = 'editinterface';
- $wgNamespaceAliases['Image'] = NS_FILE;
- $wgNamespaceAliases['Image_talk'] = NS_FILE_TALK;
- }
-
- public function tearDown() {
- foreach ( $this->savedInitialGlobals as $var => $val ) {
- $GLOBALS[$var] = $val;
- }
-
- global $wgNamespaceProtection, $wgNamespaceAliases;
-
- $wgNamespaceProtection[NS_MEDIAWIKI] = $this->savedWeirdGlobals['mw_namespace_protection'];
- $wgNamespaceAliases['Image'] = $this->savedWeirdGlobals['image_alias'];
- $wgNamespaceAliases['Image_talk'] = $this->savedWeirdGlobals['image_talk_alias'];
-
- // Restore backends
- RepoGroup::destroySingleton();
- FileBackendGroup::destroySingleton();
- }
-
- function addDBData() {
- $this->tablesUsed[] = 'site_stats';
- $this->tablesUsed[] = 'interwiki';
- # disabled for performance
- #$this->tablesUsed[] = 'image';
-
- # 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.
- */
- ), __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 ),
- __METHOD__
- );
-
- # Reinitialise the LocalisationCache to match the database state
- Language::getLocalisationCache()->unloadAll();
-
- # Clear the message cache
- MessageCache::singleton()->clear();
-
- $user = User::newFromId( 0 );
- LinkCache::singleton()->clear(); # Avoids the odd failure at creating the nullRevision
-
- # Upload DB table entries for files.
- # We will upload the actual files later. Note that if anything causes LocalFile::load()
- # to be triggered before then, it will break via maybeUpgrade() setting the fileExists
- # member to false and storing it in cache.
- $image = wfLocalFile( Title::makeTitle( NS_FILE, 'Foobar.jpg' ) );
- if ( !$this->db->selectField( 'image', '1', array( 'img_name' => $image->getName() ) ) ) {
- $image->recordUpload2(
- '', // archive name
- '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 ),
- $this->db->timestamp( '20010115123500' ), $user
- );
- }
-
- # This image will be blacklisted in [[MediaWiki:Bad image list]]
- $image = wfLocalFile( Title::makeTitle( NS_FILE, 'Bad.jpg' ) );
- if ( !$this->db->selectField( 'image', '1', array( 'img_name' => $image->getName() ) ) ) {
- $image->recordUpload2(
- '', // archive name
- '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 ),
- $this->db->timestamp( '20010115123500' ), $user
- );
- }
- }
-
-
-
-
- //ParserTest setup/teardown functions
-
- /**
- * Set up the global variables for a consistent environment for each test.
- * Ideally this should replace the global configuration entirely.
- */
- protected function setupGlobals( $opts = '', $config = '' ) {
- global $wgFileBackends;
- # Find out values for some special options.
- $lang =
- self::getOptionValue( 'language', $opts, 'en' );
- $variant =
- self::getOptionValue( 'variant', $opts, false );
- $maxtoclevel =
- self::getOptionValue( 'wgMaxTocLevel', $opts, 999 );
- $linkHolderBatchSize =
- self::getOptionValue( 'wgLinkHolderBatchSize', $opts, 1000 );
-
- $uploadDir = $this->getUploadDir();
- if ( $this->getCliArg( 'use-filebackend=' ) ) {
- if ( self::$backendToUse ) {
- $backend = self::$backendToUse;
- } else {
- $name = $this->getCliArg( 'use-filebackend=' );
- $useConfig = array();
- foreach ( $wgFileBackends as $conf ) {
- if ( $conf['name'] == $name ) {
- $useConfig = $conf;
- }
- }
- $useConfig['name'] = 'local-backend'; // swap name
- $class = $conf['class'];
- self::$backendToUse = new $class( $useConfig );
- $backend = self::$backendToUse;
- }
- } else {
- $backend = new FSFileBackend( array(
- 'name' => 'local-backend',
- 'lockManager' => 'nullLockManager',
- 'containerPaths' => array(
- 'local-public' => "$uploadDir",
- 'local-thumb' => "$uploadDir/thumb",
- )
- ) );
- }
-
- $settings = array(
- 'wgServer' => 'http://Britney-Spears',
- 'wgScript' => '/index.php',
- 'wgScriptPath' => '/',
- 'wgArticlePath' => '/wiki/$1',
- 'wgExtensionAssetsPath' => '/extensions',
- 'wgActionPaths' => array(),
- 'wgLocalFileRepo' => array(
- 'class' => 'LocalRepo',
- 'name' => 'local',
- 'url' => 'http://example.com/images',
- 'hashLevels' => 2,
- 'transformVia404' => false,
- 'backend' => $backend
- ),
- 'wgEnableUploads' => self::getOptionValue( 'wgEnableUploads', $opts, true ),
- 'wgStylePath' => '/skins',
- 'wgStyleSheetPath' => '/skins',
- 'wgSitename' => 'MediaWiki',
- 'wgLanguageCode' => $lang,
- 'wgDBprefix' => $this->db->getType() != 'oracle' ? 'unittest_' : 'ut_',
- 'wgRawHtml' => isset( $opts['rawhtml'] ),
- 'wgLang' => null,
- 'wgContLang' => null,
- 'wgNamespacesWithSubpages' => array( 0 => isset( $opts['subpage'] ) ),
- 'wgMaxTocLevel' => $maxtoclevel,
- 'wgCapitalLinks' => true,
- 'wgNoFollowLinks' => true,
- 'wgNoFollowDomainExceptions' => array(),
- 'wgThumbnailScriptPath' => false,
- 'wgUseImageResize' => false,
- 'wgUseTeX' => isset( $opts['math'] ),
- 'wgMathDirectory' => $uploadDir . '/math',
- 'wgLocaltimezone' => 'UTC',
- 'wgAllowExternalImages' => true,
- 'wgUseTidy' => false,
- 'wgDefaultLanguageVariant' => $variant,
- 'wgVariantArticlePath' => false,
- 'wgGroupPermissions' => array( '*' => array(
- 'createaccount' => true,
- 'read' => true,
- 'edit' => true,
- 'createpage' => true,
- 'createtalk' => true,
- ) ),
- 'wgNamespaceProtection' => array( NS_MEDIAWIKI => 'editinterface' ),
- 'wgDefaultExternalStore' => array(),
- 'wgForeignFileRepos' => array(),
- 'wgLinkHolderBatchSize' => $linkHolderBatchSize,
- 'wgExperimentalHtmlIds' => false,
- 'wgExternalLinkTarget' => false,
- 'wgAlwaysUseTidy' => false,
- 'wgHtml5' => true,
- 'wgWellFormedXml' => true,
- 'wgAllowMicrodataAttributes' => true,
- 'wgAdaptiveMessageCache' => true,
- 'wgUseDatabaseMessages' => true,
- );
-
- if ( $config ) {
- $configLines = explode( "\n", $config );
-
- foreach ( $configLines as $line ) {
- list( $var, $value ) = explode( '=', $line, 2 );
-
- $settings[$var] = eval( "return $value;" ); //???
- }
- }
-
- $this->savedGlobals = array();
-
- /** @since 1.20 */
- wfRunHooks( 'ParserTestGlobals', array( &$settings ) );
-
- foreach ( $settings as $var => $val ) {
- if ( array_key_exists( $var, $GLOBALS ) ) {
- $this->savedGlobals[$var] = $GLOBALS[$var];
- }
-
- $GLOBALS[$var] = $val;
- }
-
- $langObj = Language::factory( $lang );
- $GLOBALS['wgContLang'] = $langObj;
- $context = new RequestContext();
- $GLOBALS['wgLang'] = $context->getLanguage();
-
- $GLOBALS['wgMemc'] = new EmptyBagOStuff;
- $GLOBALS['wgOut'] = $context->getOutput();
- $GLOBALS['wgUser'] = $context->getUser();
-
- global $wgHooks;
-
- $wgHooks['ParserTestParser'][] = 'ParserTestParserHook::setup';
- $wgHooks['ParserGetVariableValueTs'][] = 'ParserTest::getFakeTimestamp';
-
- MagicWord::clearCache();
- RepoGroup::destroySingleton();
- FileBackendGroup::destroySingleton();
-
- # Create dummy files in storage
- $this->setupUploads();
-
- # Publish the articles after we have the final language set
- $this->publishTestArticles();
-
- # The entries saved into RepoGroup cache with previous globals will be wrong.
- RepoGroup::destroySingleton();
- FileBackendGroup::destroySingleton();
- MessageCache::destroyInstance();
-
- return $context;
- }
-
- /**
- * Get an FS upload directory (only applies to FSFileBackend)
- *
- * @return String: the directory
- */
- protected function getUploadDir() {
- if ( $this->keepUploads ) {
- $dir = wfTempDir() . '/mwParser-images';
-
- if ( is_dir( $dir ) ) {
- return $dir;
- }
- } else {
- $dir = wfTempDir() . "/mwParser-" . mt_rand() . "-images";
- }
-
- // wfDebug( "Creating upload directory $dir\n" );
- if ( file_exists( $dir ) ) {
- wfDebug( "Already exists!\n" );
- return $dir;
- }
-
- return $dir;
- }
-
- /**
- * Create a dummy uploads directory which will contain a couple
- * of files in order to pass existence tests.
- *
- * @return String: the directory
- */
- protected function setupUploads() {
- global $IP;
-
- $base = $this->getBaseDir();
- $backend = RepoGroup::singleton()->getLocalRepo()->getBackend();
- $backend->prepare( array( 'dir' => "$base/local-public/3/3a" ) );
- $backend->store( array(
- 'src' => "$IP/skins/monobook/headbg.jpg", 'dst' => "$base/local-public/3/3a/Foobar.jpg"
- ) );
- $backend->prepare( array( 'dir' => "$base/local-public/0/09" ) );
- $backend->store( array(
- 'src' => "$IP/skins/monobook/headbg.jpg", 'dst' => "$base/local-public/0/09/Bad.jpg"
- ) );
- }
-
- /**
- * Restore default values and perform any necessary clean-up
- * after each test runs.
- */
- protected function teardownGlobals() {
- $this->teardownUploads();
-
- foreach ( $this->savedGlobals as $var => $val ) {
- $GLOBALS[$var] = $val;
- }
-
- RepoGroup::destroySingleton();
- LinkCache::singleton()->clear();
- }
-
- /**
- * Remove the dummy uploads directory
- */
- private function teardownUploads() {
- if ( $this->keepUploads ) {
- return;
- }
-
- $base = $this->getBaseDir();
- // delete the files first, then the dirs.
- self::deleteFiles(
- 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",
- "$base/local-thumb/3/3a/Foobar.jpg/640px-Foobar.jpg",
- "$base/local-thumb/3/3a/Foobar.jpg/120px-Foobar.jpg",
-
- "$base/local-public/0/09/Bad.jpg",
- "$base/local-thumb/0/09/Bad.jpg",
-
- "$base/local-public/math/f/a/5/fa50b8b616463173474302ca3e63586b.png",
- )
- );
- }
-
- /**
- * Delete the specified files, if they exist.
- * @param $files Array: full paths to files to delete.
- */
- private static function deleteFiles( $files ) {
- $backend = RepoGroup::singleton()->getLocalRepo()->getBackend();
- foreach ( $files as $file ) {
- $backend->delete( array( 'src' => $file ), array( 'force' => 1 ) );
- }
- foreach ( $files as $file ) {
- $tmp = $file;
- while ( $tmp = FileBackend::parentStoragePath( $tmp ) ) {
- if ( !$backend->clean( array( 'dir' => $tmp ) )->isOK() ) {
- break;
- }
- }
- }
- }
-
- protected function getBaseDir() {
- return 'mwstore://local-backend';
- }
-
- public function parserTestProvider() {
- if ( $this->file === false ) {
- global $wgParserTestFiles;
- $this->file = $wgParserTestFiles[0];
- }
- return new TestFileIterator( $this->file, $this );
- }
-
- /**
- * Set the file from whose tests will be run by this instance
- */
- public function setParserTestFile( $filename ) {
- $this->file = $filename;
- }
-
- /**
- * @group medium
- * @dataProvider parserTestProvider
- */
- public function testParserTest( $desc, $input, $result, $opts, $config ) {
- if ( $this->regex != '' && !preg_match( '/' . $this->regex . '/', $desc ) ) {
- $this->assertTrue( true ); // XXX: don't flood output with "test made no assertions"
- //$this->markTestSkipped( 'Filtered out by the user' );
- return;
- }
-
- wfDebug( "Running parser test: $desc\n" );
-
- $opts = $this->parseOptions( $opts );
- $context = $this->setupGlobals( $opts, $config );
-
- $user = $context->getUser();
- $options = ParserOptions::newFromContext( $context );
-
- if ( isset( $opts['title'] ) ) {
- $titleText = $opts['title'];
- }
- else {
- $titleText = 'Parser test';
- }
-
- $local = isset( $opts['local'] );
- $preprocessor = isset( $opts['preprocessor'] ) ? $opts['preprocessor'] : null;
- $parser = $this->getParser( $preprocessor );
-
- $title = Title::newFromText( $titleText );
-
- if ( isset( $opts['pst'] ) ) {
- $out = $parser->preSaveTransform( $input, $title, $user, $options );
- } elseif ( isset( $opts['msg'] ) ) {
- $out = $parser->transformMsg( $input, $options, $title );
- } elseif ( isset( $opts['section'] ) ) {
- $section = $opts['section'];
- $out = $parser->getSection( $input, $section );
- } elseif ( isset( $opts['replace'] ) ) {
- $section = $opts['replace'][0];
- $replace = $opts['replace'][1];
- $out = $parser->replaceSection( $input, $section, $replace );
- } elseif ( isset( $opts['comment'] ) ) {
- $out = Linker::formatComment( $input, $title, $local );
- } elseif ( isset( $opts['preload'] ) ) {
- $out = $parser->getpreloadText( $input, $title, $options );
- } else {
- $output = $parser->parse( $input, $title, $options, true, true, 1337 );
- $out = $output->getText();
-
- if ( isset( $opts['showtitle'] ) ) {
- if ( $output->getTitleText() ) {
- $title = $output->getTitleText();
- }
-
- $out = "$title\n$out";
- }
-
- if ( isset( $opts['ill'] ) ) {
- $out = $this->tidy( implode( ' ', $output->getLanguageLinks() ) );
- } elseif ( isset( $opts['cat'] ) ) {
- $outputPage = $context->getOutput();
- $outputPage->addCategoryLinks( $output->getCategories() );
- $cats = $outputPage->getCategoryLinks();
-
- if ( isset( $cats['normal'] ) ) {
- $out = $this->tidy( implode( ' ', $cats['normal'] ) );
- } else {
- $out = '';
- }
- }
- $parser->mPreprocessor = null;
-
- $result = $this->tidy( $result );
- }
-
- $this->teardownGlobals();
-
- $this->assertEquals( $result, $out, $desc );
- }
-
- /**
- * Run a fuzz test series
- * Draw input from a set of test files
- *
- * @todo fixme Needs some work to not eat memory until the world explodes
- *
- * @group ParserFuzz
- */
- function testFuzzTests() {
- global $wgParserTestFiles;
-
- $files = $wgParserTestFiles;
-
- if( $this->getCliArg( 'file=' ) ) {
- $files = array( $this->getCliArg( 'file=' ) );
- }
-
- $dict = $this->getFuzzInput( $files );
- $dictSize = strlen( $dict );
- $logMaxLength = log( $this->maxFuzzTestLength );
-
- ini_set( 'memory_limit', $this->memoryLimit * 1048576 );
-
- $user = new User;
- $opts = ParserOptions::newFromUser( $user );
- $title = Title::makeTitle( NS_MAIN, 'Parser_test' );
-
- $id = 1;
-
- while ( true ) {
-
- // Generate test input
- mt_srand( ++$this->fuzzSeed );
- $totalLength = mt_rand( 1, $this->maxFuzzTestLength );
- $input = '';
-
- while ( strlen( $input ) < $totalLength ) {
- $logHairLength = mt_rand( 0, 1000000 ) / 1000000 * $logMaxLength;
- $hairLength = min( intval( exp( $logHairLength ) ), $dictSize );
- $offset = mt_rand( 0, $dictSize - $hairLength );
- $input .= substr( $dict, $offset, $hairLength );
- }
-
- $this->setupGlobals();
- $parser = $this->getParser();
-
- // Run the test
- try {
- $parser->parse( $input, $title, $opts );
- $this->assertTrue( true, "Test $id, fuzz seed {$this->fuzzSeed}" );
- } catch ( Exception $exception ) {
- $input_dump = sprintf( "string(%d) \"%s\"\n", strlen( $input ), $input );
-
- $this->assertTrue( false, "Test $id, fuzz seed {$this->fuzzSeed}. \n\nInput: $input_dump\n\nError: {$exception->getMessage()}\n\nBacktrace: {$exception->getTraceAsString()}" );
- }
-
- $this->teardownGlobals();
- $parser->__destruct();
-
- if ( $id % 100 == 0 ) {
- $usage = intval( memory_get_usage( true ) / $this->memoryLimit / 1048576 * 100 );
- //echo "{$this->fuzzSeed}: $numSuccess/$numTotal (mem: $usage%)\n";
- if ( $usage > 90 ) {
- $ret = "Out of memory:\n";
- $memStats = $this->getMemoryBreakdown();
-
- foreach ( $memStats as $name => $usage ) {
- $ret .= "$name: $usage\n";
- }
-
- throw new MWException( $ret );
- }
- }
-
- $id++;
-
- }
- }
-
- //Various getter functions
-
- /**
- * Get an input dictionary from a set of parser test files
- */
- function getFuzzInput( $filenames ) {
- $dict = '';
-
- foreach ( $filenames as $filename ) {
- $contents = file_get_contents( $filename );
- preg_match_all( '/!!\s*input\n(.*?)\n!!\s*result/s', $contents, $matches );
-
- foreach ( $matches[1] as $match ) {
- $dict .= $match . "\n";
- }
- }
-
- return $dict;
- }
-
- /**
- * Get a memory usage breakdown
- */
- function getMemoryBreakdown() {
- $memStats = array();
-
- foreach ( $GLOBALS as $name => $value ) {
- $memStats['$' . $name] = strlen( serialize( $value ) );
- }
-
- $classes = get_declared_classes();
-
- foreach ( $classes as $class ) {
- $rc = new ReflectionClass( $class );
- $props = $rc->getStaticProperties();
- $memStats[$class] = strlen( serialize( $props ) );
- $methods = $rc->getMethods();
-
- foreach ( $methods as $method ) {
- $memStats[$class] += strlen( serialize( $method->getStaticVariables() ) );
- }
- }
-
- $functions = get_defined_functions();
-
- foreach ( $functions['user'] as $function ) {
- $rf = new ReflectionFunction( $function );
- $memStats["$function()"] = strlen( serialize( $rf->getStaticVariables() ) );
- }
-
- asort( $memStats );
-
- return $memStats;
- }
-
- /**
- * Get a Parser object
- */
- function getParser( $preprocessor = null ) {
- global $wgParserConf;
-
- $class = $wgParserConf['class'];
- $parser = new $class( array( 'preprocessorClass' => $preprocessor ) + $wgParserConf );
-
- wfRunHooks( 'ParserTestParser', array( &$parser ) );
-
- return $parser;
- }
-
- //Various action functions
-
- public function addArticle( $name, $text, $line ) {
- self::$articles[$name] = array( $text, $line );
- }
-
- public function publishTestArticles() {
- if ( empty( self::$articles ) ) {
- return;
- }
-
- foreach ( self::$articles as $name => $info ) {
- list( $text, $line ) = $info;
- ParserTest::addArticle( $name, $text, $line, 'ignoreduplicate' );
- }
- }
-
- /**
- * Steal a callback function from the primary parser, save it for
- * application to our scary parser. If the hook is not installed,
- * abort processing of this file.
- *
- * @param $name String
- * @return Bool true if tag hook is present
- */
- public function requireHook( $name ) {
- global $wgParser;
- $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.
- return isset( $wgParser->mFunctionHooks[$name] );
- }
- //Various "cleanup" functions
-
- /**
- * Run the "tidy" command on text if the $wgUseTidy
- * global is true
- *
- * @param $text String: the text to tidy
- * @return String
- */
- protected function tidy( $text ) {
- global $wgUseTidy;
-
- if ( $wgUseTidy ) {
- $text = MWTidy::tidy( $text );
- }
-
- return $text;
- }
-
- /**
- * Remove last character if it is a newline
- */
- public function removeEndingNewline( $s ) {
- if ( substr( $s, -1 ) === "\n" ) {
- return substr( $s, 0, -1 );
- }
- else {
- return $s;
- }
- }
-
- //Test options parser functions
-
- protected function parseOptions( $instring ) {
- $opts = array();
- // foo
- // foo=bar
- // foo="bar baz"
- // foo=[[bar baz]]
- // foo=bar,"baz quux"
- $regex = '/\b
- ([\w-]+) # Key
- \b
- (?:\s*
- = # First sub-value
- \s*
- (
- "
- [^"]* # Quoted val
- "
- |
- \[\[
- [^]]* # Link target
- \]\]
- |
- [\w-]+ # Plain word
- )
- (?:\s*
- , # Sub-vals 1..N
- \s*
- (
- "[^"]*" # Quoted val
- |
- \[\[[^]]*\]\] # Link target
- |
- [\w-]+ # Plain word
- )
- )*
- )?
- /x';
-
- if ( preg_match_all( $regex, $instring, $matches, PREG_SET_ORDER ) ) {
- foreach ( $matches as $bits ) {
- array_shift( $bits );
- $key = strtolower( array_shift( $bits ) );
- if ( count( $bits ) == 0 ) {
- $opts[$key] = true;
- } elseif ( count( $bits ) == 1 ) {
- $opts[$key] = $this->cleanupOption( array_shift( $bits ) );
- } else {
- // Array!
- $opts[$key] = array_map( array( $this, 'cleanupOption' ), $bits );
- }
- }
- }
- return $opts;
- }
-
- protected function cleanupOption( $opt ) {
- if ( substr( $opt, 0, 1 ) == '"' ) {
- return substr( $opt, 1, -1 );
- }
-
- if ( substr( $opt, 0, 2 ) == '[[' ) {
- return substr( $opt, 2, -2 );
- }
- return $opt;
- }
-
- /**
- * Use a regex to find out the value of an option
- * @param $key String: name of option val to retrieve
- * @param $opts Options array to look in
- * @param $default Mixed: default value returned if not found
- */
- protected static function getOptionValue( $key, $opts, $default ) {
- $key = strtolower( $key );
-
- if ( isset( $opts[$key] ) ) {
- return $opts[$key];
- } else {
- return $default;
- }
- }
-}
diff --git a/tests/phpunit/includes/parser/ParserMethodsTest.php b/tests/phpunit/includes/parser/ParserMethodsTest.php
deleted file mode 100644
index dea406c3..00000000
--- a/tests/phpunit/includes/parser/ParserMethodsTest.php
+++ /dev/null
@@ -1,33 +0,0 @@
-~~~',
- 'hello \'\'this\'\' is ~~~',
- ),
- );
- }
-
- /**
- * @dataProvider dataPreSaveTransform
- */
- public function testPreSaveTransform( $text, $expected ) {
- global $wgParser;
-
- $title = Title::newFromText( str_replace( '::', '__', __METHOD__ ) );
- $user = new User();
- $user->setName( "127.0.0.1" );
- $popts = ParserOptions::newFromUser( $user );
- $text = $wgParser->preSaveTransform( $text, $title, $user, $popts );
-
- $this->assertEquals( $expected, $text );
- }
-
- // TODO: Add tests for cleanSig() / cleanSigInSig(), getSection(), replaceSection(), getPreloadText()
-}
-
diff --git a/tests/phpunit/includes/parser/ParserPreloadTest.php b/tests/phpunit/includes/parser/ParserPreloadTest.php
deleted file mode 100644
index 0e8ef530..00000000
--- a/tests/phpunit/includes/parser/ParserPreloadTest.php
+++ /dev/null
@@ -1,67 +0,0 @@
-testParserOptions = new ParserOptions();
-
- $this->testParser = new Parser();
- $this->testParser->Options( $this->testParserOptions );
- $this->testParser->clearState();
-
- $this->title = Title::newFromText( 'Preload Test' );
- }
-
- function tearDown() {
- unset( $this->testParser );
- unset( $this->title );
- }
-
- /**
- * @covers Parser::getPreloadText
- */
- function testPreloadSimpleText() {
- $this->assertPreloaded( 'simple', 'simple' );
- }
-
- /**
- * @covers Parser::getPreloadText
- */
- function testPreloadedPreIsUnstripped() {
- $this->assertPreloaded(
- 'monospaced
',
- 'monospaced
',
- ' in preloaded text must be unstripped (bug 27467)'
- );
- }
-
- /**
- * @covers Parser::getPreloadText
- */
- function testPreloadedNowikiIsUnstripped() {
- $this->assertPreloaded(
- '[[Dummy title]]',
- '[[Dummy title]]',
- ' in preloaded text must be unstripped (bug 27467)'
- );
- }
-
- function assertPreloaded( $expected, $text, $msg='') {
- $this->assertEquals(
- $expected,
- $this->testParser->getPreloadText(
- $text,
- $this->title,
- $this->testParserOptions
- ),
- $msg
- );
- }
-
-}
diff --git a/tests/phpunit/includes/parser/PreprocessorTest.php b/tests/phpunit/includes/parser/PreprocessorTest.php
deleted file mode 100644
index fee56748..00000000
--- a/tests/phpunit/includes/parser/PreprocessorTest.php
+++ /dev/null
@@ -1,233 +0,0 @@
-mOptions = new ParserOptions();
- $name = isset( $wgParserConf['preprocessorClass'] ) ? $wgParserConf['preprocessorClass'] : 'Preprocessor_DOM';
-
- $this->mPreprocessor = new $name( $this );
- }
-
- function getStripList() {
- return array( 'gallery', 'display map' /* Used by Maps, see r80025 CR */, '/foo' );
- }
-
- function provideCases() {
- return array(
- array( "Foo", "Foo" ),
- array( "", "<!-- Foo -->" ),
- array( "", "<!-- Foo --><!-- Bar -->" ),
- array( " ", "<!-- Foo --> <!-- Bar -->" ),
- array( " \n ", "<!-- Foo --> \n <!-- Bar -->" ),
- array( " \n \n", "<!-- Foo --> \n <!-- Bar -->\n" ),
- array( " \n", "<!-- Foo --> <!-- Bar -->\n" ),
- array( "Bar", "<!-->Bar" ),
- array( "\n== Baz ==\n", "== Foo ==\n <!-- Bar -->\n== Baz ==\n" ),
- array( "", "gallery" ),
- array( "Foo Bar", "Foo gallery Bar" ),
- array( "", "gallery</gallery>" ),
- array( " ", "<foo> gallery</gallery>" ),
- array( " ", "<foo> gallery<gallery></gallery>" ),
- array( " Foo bar ", "<noinclude> Foo bar </noinclude>" ),
- array( "\n{{Foo}}\n", "<noinclude>\nFoo\n</noinclude>" ),
- array( "\n{{Foo}}\n\n", "<noinclude>\nFoo\n</noinclude>\n" ),
- array( "foo bar", "galleryfoo bar" ),
- array( "<{{foo}}>", "<foo>" ),
- array( "<{{{foo}}}>", "<foo>" ),
- array( "", "gallery</gallery</gallery>" ),
- array( "=== Foo === ", "=== Foo === " ),
- array( "=== Foo === ", "==<!-- -->= Foo === " ),
- array( "=== Foo === ", "=== Foo ==<!-- -->= " ),
- array( "=== Foo ===\n", "=== Foo ===<!-- -->\n" ),
- array( "=== Foo === \n", "=== Foo ===<!-- --> <!-- -->\n" ),
- array( "== Foo ==\n== Bar == \n", "== Foo ==\n== Bar == \n" ),
- array( "===========", "===========" ),
- array( "Foo\n=\n==\n=\n", "Foo\n=\n==\n=\n" ),
- array( "{{Foo}}", "Foo" ),
- array( "\n{{Foo}}", "\nFoo" ),
- array( "{{Foo|bar}}", "Foobar" ),
- array( "{{Foo|bar}}a", "Foobara" ),
- array( "{{Foo|bar|baz}}", "Foobarbaz" ),
- array( "{{Foo|1=bar}}", "Foo1=bar" ),
- array( "{{Foo|=bar}}", "Foo=bar" ),
- array( "{{Foo|bar=baz}}", "Foobar=baz" ),
- array( "{{Foo|{{bar}}=baz}}", "Foobar=baz" ),
- array( "{{Foo|1=bar|baz}}", "Foo1=barbaz" ),
- array( "{{Foo|1=bar|2=baz}}", "Foo1=bar2=baz" ),
- array( "{{Foo|bar|foo=baz}}", "Foobarfoo=baz" ),
- array( "{{{1}}}", "1" ),
- array( "{{{1|}}}", "1" ),
- array( "{{{Foo}}}", "Foo" ),
- array( "{{{Foo|}}}", "Foo" ),
- array( "{{{Foo|bar|baz}}}", "Foobarbaz" ),
- array( "{{Foo}}", "{<!-- -->{Foo}}" ),
- array( "{{{{Foobar}}}}", "{Foobar}" ),
- array( "{{{ {{Foo}} }}}", " Foo " ),
- array( "{{ {{{Foo}}} }}", " Foo " ),
- array( "{{{{{Foo}}}}}", "Foo" ),
- array( "{{{{{Foo}} }}}", "Foo " ),
- array( "{{{{{{Foo}}}}}}", "Foo" ),
- array( "{{{{{{Foo}}}}}", "{Foo" ),
- array( "[[[Foo]]", "[[[Foo]]" ),
- array( "{{Foo|[[[[bar]]|baz]]}}", "Foo[[[[bar]]|baz]]" ), // This test is important, since it means the difference between having the [[ rule stacked or not
- array( "{{Foo|[[[[bar]|baz]]}}", "{{Foo|[[[[bar]|baz]]}}" ),
- array( "{{Foo|Foo [[[[bar]|baz]]}}", "{{Foo|Foo [[[[bar]|baz]]}}" ),
- array( "Foo BarBaz", "Foo display mapBar</display map >Baz" ),
- array( "Foo BarBaz", "Foo display map fooBar</display map >Baz" ),
- array( "Foo ", "Foo gallery bar="baz" " ),
- array( "Foo ", "Foo gallery bar="1" baz=2 " ),
- array( "Foo/foo>", "/fooFoo<//foo>" ), # Worth blacklisting IMHO
- array( "{{#ifexpr: ({{{1|1}}} = 2) | Foo | Bar }}", "#ifexpr: (11 = 2) Foo Bar "),
- array( "{{#if: {{{1|}}} | Foo | {{Bar}} }}", "#if: 1 Foo Bar "),
- array( "{{#if: {{{1|}}} | Foo | [[Bar]] }}", "#if: 1 Foo [[Bar]] "),
- array( "{{#if: {{{1|}}} | [[Foo]] | Bar }}", "#if: 1 [[Foo]] Bar "),
- array( "{{#if: {{{1|}}} | 1 | {{#if: {{{1|}}} | 2 | 3 }} }}", "#if: 1 1 #if: 1 2 3 "),
- array( "{{ {{Foo}}", "{{ Foo"),
- array( "{{Foobar {{Foo}} {{Bar}} {{Baz}} ", "{{Foobar Foo Bar Baz "),
- array( "[[Foo]] |", "[[Foo]] |"),
- array( "{{Foo|Bar|", "{{Foo|Bar|"),
- array( "[[Foo]", "[[Foo]"),
- array( "[[Foo|Bar]", "[[Foo|Bar]"),
- array( "{{Foo| [[Bar] }}", "{{Foo| [[Bar] }}"),
- array( "{{Foo| [[Bar|Baz] }}", "{{Foo| [[Bar|Baz] }}"),
- array( "{{Foo|bar=[[baz]}}", "{{Foo|bar=[[baz]}}"),
- array( "{{foo|", "{{foo|"),
- array( "{{foo|}", "{{foo|}"),
- array( "{{foo|} }}", "foo} "),
- array( "{{foo|bar=|}", "{{foo|bar=|}"),
- array( "{{Foo|} Bar=", "{{Foo|} Bar="),
- array( "{{Foo|} Bar=}}", "Foo} Bar="),
- /* array( file_get_contents( __DIR__ . '/QuoteQuran.txt' ), file_get_contents( __DIR__ . '/QuoteQuranExpanded.txt' ) ), */
- );
- }
-
- /**
- * Get XML preprocessor tree from the preprocessor (which may not be the
- * native XML-based one).
- *
- * @param string $wikiText
- * @return string
- */
- function preprocessToXml( $wikiText ) {
- if ( method_exists( $this->mPreprocessor, 'preprocessToXml' ) ) {
- return $this->normalizeXml( $this->mPreprocessor->preprocessToXml( $wikiText ) );
- }
-
- $dom = $this->mPreprocessor->preprocessToObj( $wikiText );
- if ( is_callable( array( $dom, 'saveXML' ) ) ) {
- return $dom->saveXML();
- } else {
- return $this->normalizeXml( $dom->__toString() );
- }
- }
-
- /**
- * Normalize XML string to the form that a DOMDocument saves out.
- *
- * @param string $xml
- * @return string
- */
- function normalizeXml( $xml ) {
- return preg_replace( '!<([a-z]+)/>!', '<$1>$1>', str_replace( ' />', '/>', $xml ) );
-
- $dom = new DOMDocument();
- // 1 << 19 == XML_PARSE_HUGE, needed so newer versions of libxml2 don't barf when the XML is >256 levels deep
- $dom->loadXML( $xml, 1 << 19 );
- return $dom->saveXML();
- }
-
- /**
- * @dataProvider provideCases
- */
- function testPreprocessorOutput( $wikiText, $expectedXml ) {
- $this->assertEquals( $this->normalizeXml( $expectedXml ), $this->preprocessToXml( $wikiText ) );
- }
-
- /**
- * These are more complex test cases taken out of wiki articles.
- */
- function provideFiles() {
- return array(
- array( "QuoteQuran" ), # http://en.wikipedia.org/w/index.php?title=Template:QuoteQuran/sandbox&oldid=237348988 GFDL + CC-BY-SA by Striver
- array( "Factorial" ), # http://en.wikipedia.org/w/index.php?title=Template:Factorial&oldid=98548758 GFDL + CC-BY-SA by Polonium
- array( "All_system_messages" ), # http://tl.wiktionary.org/w/index.php?title=Suleras:All_system_messages&oldid=2765 GPL text generated by MediaWiki
- array( "Fundraising" ), # http://tl.wiktionary.org/w/index.php?title=MediaWiki:Sitenotice&oldid=5716 GFDL + CC-BY-SA, copied there by Sky Harbor.
- );
- }
-
- /**
- * @dataProvider provideFiles
- */
- function testPreprocessorOutputFiles( $filename ) {
- $folder = __DIR__ . "/../../../parser/preprocess";
- $wikiText = file_get_contents( "$folder/$filename.txt" );
- $output = $this->preprocessToXml( $wikiText );
-
- $expectedFilename = "$folder/$filename.expected";
- if ( file_exists( $expectedFilename ) ) {
- $expectedXml = $this->normalizeXml( file_get_contents( $expectedFilename ) );
- $this->assertEquals( $expectedXml, $output );
- } else {
- $tempFilename = tempnam( $folder, "$filename." );
- file_put_contents( $tempFilename, $output );
- $this->markTestIncomplete( "File $expectedFilename missing. Output stored as $tempFilename" );
- }
- }
-
- /**
- * Tests from Bug 28642 · https://bugzilla.wikimedia.org/28642
- */
- function provideHeadings() {
- return array( /* These should become headings: */
- array( "== h ==", "== h ==<!--c1-->" ),
- array( "== h == ", "== h == <!--c1-->" ),
- array( "== h == ", "== h ==<!--c1--> " ),
- array( "== h == ", "== h == <!--c1--> " ),
- array( "== h ==", "== h ==<!--c1--><!--c2-->" ),
- array( "== h == ", "== h == <!--c1--><!--c2-->" ),
- array( "== h == ", "== h ==<!--c1--><!--c2--> " ),
- array( "== h == ", "== h == <!--c1--><!--c2--> " ),
- array( "== h == ", "== h == <!--c1--> <!--c2-->" ),
- array( "== h == ", "== h ==<!--c1--> <!--c2--> " ),
- array( "== h == ", "== h == <!--c1--> <!--c2--> " ),
- array( "== h ==", "== h ==<!--c1--><!--c2--><!--c3-->" ),
- array( "== h == ", "== h ==<!--c1--> <!--c2--><!--c3-->" ),
- array( "== h == ", "== h ==<!--c1--><!--c2--> <!--c3-->" ),
- array( "== h == ", "== h ==<!--c1--> <!--c2--> <!--c3-->" ),
- array( "== h == ", "== h == <!--c1--><!--c2--><!--c3-->" ),
- array( "== h == ", "== h == <!--c1--> <!--c2--><!--c3-->" ),
- array( "== h == ", "== h == <!--c1--><!--c2--> <!--c3-->" ),
- array( "== h == ", "== h == <!--c1--> <!--c2--> <!--c3-->" ),
- array( "== h == ", "== h ==<!--c1--><!--c2--><!--c3--> " ),
- array( "== h == ", "== h ==<!--c1--> <!--c2--><!--c3--> " ),
- array( "== h == ", "== h ==<!--c1--><!--c2--> <!--c3--> " ),
- array( "== h == ", "== h ==<!--c1--> <!--c2--> <!--c3--> " ),
- array( "== h == ", "== h == <!--c1--><!--c2--><!--c3--> " ),
- array( "== h == ", "== h == <!--c1--> <!--c2--><!--c3--> " ),
- array( "== h == ", "== h == <!--c1--><!--c2--> <!--c3--> " ),
- array( "== h == ", "== h == <!--c1--> <!--c2--> <!--c3--> " ),
-
- /* These are not working: */
- array( "== h == ", "== h ==<!--c1--> <!--c2-->" ),
- array( "== h == ", "== h == <!--c1--> <!--c2-->" ),
- array( "== h == ", "== h ==<!--c1--> <!--c2--> " ),
- array( "== h == x ", "== h == x <!--c1--><!--c2--><!--c3--> " ),
- array( "== h == x ", "== h ==<!--c1--> x <!--c2--><!--c3--> " ),
- array( "== h == x ", "== h ==<!--c1--><!--c2--><!--c3--> x " ),
- );
- }
-
- /**
- * @dataProvider provideHeadings
- */
- function testHeadings( $wikiText, $expectedXml ) {
- $this->assertEquals( $this->normalizeXml( $expectedXml ), $this->preprocessToXml( $wikiText ) );
- }
-}
-
diff --git a/tests/phpunit/includes/parser/TagHooksTest.php b/tests/phpunit/includes/parser/TagHooksTest.php
deleted file mode 100644
index 713ce846..00000000
--- a/tests/phpunit/includes/parser/TagHooksTest.php
+++ /dev/null
@@ -1,77 +0,0 @@
-bar" ), array( "foo\nbar" ), array( "foo\rbar" ) );
- }
-
- /**
- * @dataProvider provideValidNames
- */
- function testTagHooks( $tag ) {
- global $wgParserConf;
- $parser = new Parser( $wgParserConf );
-
- $parser->setHook( $tag, array( $this, 'tagCallback' ) );
- $parserOutput = $parser->parse( "Foo<$tag>Bar$tag>Baz", Title::newFromText( 'Test' ), new ParserOptions );
- $this->assertEquals( "FooOneBaz\n
", $parserOutput->getText() );
-
- $parser->mPreprocessor = null; # Break the Parser <-> Preprocessor cycle
- }
-
- /**
- * @dataProvider provideBadNames
- * @expectedException MWException
- */
- function testBadTagHooks( $tag ) {
- global $wgParserConf;
- $parser = new Parser( $wgParserConf );
-
- $parser->setHook( $tag, array( $this, 'tagCallback' ) );
- $parser->parse( "Foo<$tag>Bar$tag>Baz", Title::newFromText( 'Test' ), new ParserOptions );
- $this->fail('Exception not thrown.');
- }
-
- /**
- * @dataProvider provideValidNames
- */
- function testFunctionTagHooks( $tag ) {
- global $wgParserConf;
- $parser = new Parser( $wgParserConf );
-
- $parser->setFunctionTagHook( $tag, array( $this, 'functionTagCallback' ), 0 );
- $parserOutput = $parser->parse( "Foo<$tag>Bar$tag>Baz", Title::newFromText( 'Test' ), new ParserOptions );
- $this->assertEquals( "FooOneBaz\n
", $parserOutput->getText() );
-
- $parser->mPreprocessor = null; # Break the Parser <-> Preprocessor cycle
- }
-
- /**
- * @dataProvider provideBadNames
- * @expectedException MWException
- */
- function testBadFunctionTagHooks( $tag ) {
- global $wgParserConf;
- $parser = new Parser( $wgParserConf );
-
- $parser->setFunctionTagHook( $tag, array( $this, 'functionTagCallback' ), SFH_OBJECT_ARGS );
- $parser->parse( "Foo<$tag>Bar$tag>Baz", Title::newFromText( 'Test' ), new ParserOptions );
- $this->fail('Exception not thrown.');
- }
-
- function tagCallback( $text, $params, $parser ) {
- return str_rot13( $text );
- }
-
- function functionTagCallback( &$parser, $frame, $code, $attribs ) {
- return str_rot13( $code );
- }
-}
diff --git a/tests/phpunit/includes/search/SearchEngineTest.php b/tests/phpunit/includes/search/SearchEngineTest.php
deleted file mode 100644
index 957907c7..00000000
--- a/tests/phpunit/includes/search/SearchEngineTest.php
+++ /dev/null
@@ -1,163 +0,0 @@
-search );
- }
-
- /**
- * Checks for database type & version.
- * Will skip current test if DB does not support search.
- */
- function setUp() {
- parent::setUp();
- // Search tests require MySQL or SQLite with FTS
- # Get database type and version
- $dbType = $this->db->getType();
- $dbSupported =
- ($dbType === 'mysql')
- || ( $dbType === 'sqlite' && $this->db->getFulltextSearchModule() == 'FTS3' );
-
- if( !$dbSupported ) {
- $this->markTestSkipped( "MySQL or SQLite with FTS3 only" );
- }
-
- $searchType = $this->db->getSearchEngine();
- $this->search = new $searchType( $this->db );
- }
-
- function pageExists( $title ) {
- return false;
- }
-
- function addDBData() {
- if ( $this->pageExists( 'Not_Main_Page' ) ) {
- 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 );
- }
-
- function fetchIds( $results ) {
- $this->assertTrue( is_object( $results ) );
-
- $matches = array();
- $row = $results->next();
- while ( $row ) {
- $matches[] = $row->getTitle()->getPrefixedText();
- $row = $results->next();
- }
- $results->free();
- # Search is not guaranteed to return results in a certain order;
- # sort them numerically so we will compare simply that we received
- # the expected matches.
- sort( $matches );
- return $matches;
- }
-
- /**
- * Insert a new page
- *
- * @param $pageName String: page name
- * @param $text String: page's content
- * @param $n Integer: unused
- */
- function insertPage( $pageName, $text, $ns ) {
- $title = Title::newFromText( $pageName );
-
- $user = User::newFromName( 'WikiSysop' );
- $comment = 'Search Test';
-
- // avoid memory leak...?
- LinkCache::singleton()->clear();
-
- $page = WikiPage::factory( $title );
- $page->doEdit( $text, $comment, 0, false, $user );
-
- $this->pageList[] = array( $title, $page->getId() );
-
- return true;
- }
-
- function testFullWidth() {
- $this->assertEquals(
- array( 'FullOneUp', 'FullTwoLow', 'HalfOneUp', 'HalfTwoLow' ),
- $this->fetchIds( $this->search->searchText( 'AZ' ) ),
- "Search for normalized from Half-width Upper" );
- $this->assertEquals(
- array( 'FullOneUp', 'FullTwoLow', 'HalfOneUp', 'HalfTwoLow' ),
- $this->fetchIds( $this->search->searchText( 'az' ) ),
- "Search for normalized from Half-width Lower" );
- $this->assertEquals(
- array( 'FullOneUp', 'FullTwoLow', 'HalfOneUp', 'HalfTwoLow' ),
- $this->fetchIds( $this->search->searchText( 'AZ' ) ),
- "Search for normalized from Full-width Upper" );
- $this->assertEquals(
- array( 'FullOneUp', 'FullTwoLow', 'HalfOneUp', 'HalfTwoLow' ),
- $this->fetchIds( $this->search->searchText( 'az' ) ),
- "Search for normalized from Full-width Lower" );
- }
-
- function testTextSearch() {
- $this->assertEquals(
- array( 'Smithee' ),
- $this->fetchIds( $this->search->searchText( 'smithee' ) ),
- "Plain search failed" );
- }
-
- function testTextPowerSearch() {
- $this->search->setNamespaces( array( 0, 1, 4 ) );
- $this->assertEquals(
- array(
- 'Smithee',
- 'Talk:Not Main Page',
- ),
- $this->fetchIds( $this->search->searchText( 'smithee' ) ),
- "Power search failed" );
- }
-
- function testTitleSearch() {
- $this->assertEquals(
- array(
- 'Alan Smithee',
- 'Smithee',
- ),
- $this->fetchIds( $this->search->searchTitle( 'smithee' ) ),
- "Title search failed" );
- }
-
- function testTextTitlePowerSearch() {
- $this->search->setNamespaces( array( 0, 1, 4 ) );
- $this->assertEquals(
- array(
- 'Alan Smithee',
- 'Smithee',
- 'Talk:Smithee',
- ),
- $this->fetchIds( $this->search->searchTitle( 'smithee' ) ),
- "Title power search failed" );
- }
-
-}
diff --git a/tests/phpunit/includes/search/SearchUpdateTest.php b/tests/phpunit/includes/search/SearchUpdateTest.php
deleted file mode 100644
index 6e49a9a1..00000000
--- a/tests/phpunit/includes/search/SearchUpdateTest.php
+++ /dev/null
@@ -1,90 +0,0 @@
-doUpdate();
- return array( MockSearch::$title, MockSearch::$text );
- }
-
- function updateText( $text ) {
- list( , $resultText ) = $this->update( $text );
- $resultText = trim( $resultText ); // abstract from some implementation details
- return $resultText;
- }
-
- function setUp() {
- global $wgSearchType;
-
- self::$searchType = $wgSearchType;
- $wgSearchType = 'MockSearch';
- }
-
- function tearDown() {
- global $wgSearchType;
-
- $wgSearchType = self::$searchType;
- }
-
- function testUpdateText() {
- $this->assertEquals(
- 'test',
- $this->updateText( 'TeSt
' ),
- 'HTML stripped, text lowercased'
- );
-
- $this->assertEquals(
- 'foo bar boz quux',
- $this->updateText( <<
- foo |
bar
- boz |
quux
-
-EOT
- ), 'Stripping HTML tables' );
-
- $this->assertEquals(
- 'a b',
- $this->updateText( 'a > b' ),
- 'Handle unclosed tags'
- );
-
- $text = str_pad( "foo assertNotEquals(
- '',
- $this->updateText( $text ),
- 'Bug 18609'
- );
- }
-
- function testBug32712() {
- $text = "text „http://example.com“ text";
- $result = $this->updateText( $text );
- $processed = preg_replace( '/Q/u', 'Q', $result );
- $this->assertTrue(
- $processed != '',
- 'Link surrounded by unicode quotes should not fail UTF-8 validation'
- );
- }
-}
diff --git a/tests/phpunit/includes/specials/QueryAllSpecialPagesTest.php b/tests/phpunit/includes/specials/QueryAllSpecialPagesTest.php
deleted file mode 100644
index a33c7b68..00000000
--- a/tests/phpunit/includes/specials/QueryAllSpecialPagesTest.php
+++ /dev/null
@@ -1,79 +0,0 @@
-manualTest ) ) {
- $this->queryPages[$class] = new $class;
- }
- }
- }
-
- /**
- * Test SQL for each of our QueryPages objects
- * @group Database
- */
- function testQuerypageSqlQuery() {
- global $wgDBtype;
-
- foreach( $this->queryPages as $page ) {
-
- // With MySQL, skips special pages reopening a temporary table
- // See http://bugs.mysql.com/bug.php?id=10327
- 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;
- }
-
- $msg = "SQL query for page {$page->getName()} should give a result wrapper object" ;
-
- $result = $page->reallyDoQuery( 50 );
- if( $result instanceof ResultWrapper ) {
- $this->assertTrue( true, $msg );
- } else {
- $this->assertFalse( false, $msg );
- }
- }
- }
-}
diff --git a/tests/phpunit/includes/specials/SpecialRecentchangesTest.php b/tests/phpunit/includes/specials/SpecialRecentchangesTest.php
deleted file mode 100644
index 2e4f4b09..00000000
--- a/tests/phpunit/includes/specials/SpecialRecentchangesTest.php
+++ /dev/null
@@ -1,132 +0,0 @@
-setRequest( new FauxRequest( $requestOptions ) );
-
- # setup the rc object
- $this->rc = new SpecialRecentChanges();
- $this->rc->setContext( $context );
- $formOptions = $this->rc->setup( null );
-
- # Filter out rc_timestamp conditions which depends on the test runtime
- # This condition is not needed as of march 2, 2011 -- hashar
- # @todo FIXME: Find a way to generate the correct rc_timestamp
- $queryConditions = array_filter(
- $this->rc->buildMainQueryConds( $formOptions ),
- 'SpecialRecentchangesTest::filterOutRcTimestampCondition'
- );
-
- $this->assertEquals(
- $expected,
- $queryConditions,
- $message
- );
- }
-
- /** return false if condition begin with 'rc_timestamp ' */
- private static function filterOutRcTimestampCondition( $var ) {
- return (false === strpos( $var, 'rc_timestamp ' ));
-
- }
-
- public function testRcNsFilter() {
- $this->assertConditions(
- array( # expected
- 'rc_bot' => 0,
- #0 => "rc_timestamp >= '20110223000000'",
- 1 => "rc_namespace = '0'",
- ),
- array(
- 'namespace' => NS_MAIN,
- ),
- "rc conditions with no options (aka default setting)"
- );
- }
-
- public function testRcNsFilterInversion() {
- $this->assertConditions(
- array( # expected
- #0 => "rc_timestamp >= '20110223000000'",
- 'rc_bot' => 0,
- 1 => sprintf( "rc_namespace != '%s'", NS_MAIN ),
- ),
- array(
- 'namespace' => NS_MAIN,
- 'invert' => 1,
- ),
- "rc conditions with namespace inverted"
- );
- }
-
- /**
- * @bug 2429
- * @dataProvider provideNamespacesAssociations
- */
- public function testRcNsFilterAssociation( $ns1, $ns2 ) {
- $this->assertConditions(
- array( # expected
- #0 => "rc_timestamp >= '20110223000000'",
- 'rc_bot' => 0,
- 1 => sprintf( "(rc_namespace = '%s' OR rc_namespace = '%s')", $ns1, $ns2 ),
- ),
- array(
- 'namespace' => $ns1,
- 'associated' => 1,
- ),
- "rc conditions with namespace inverted"
- );
- }
-
- /**
- * @bug 2429
- * @dataProvider provideNamespacesAssociations
- */
- public function testRcNsFilterAssociationWithInversion( $ns1, $ns2 ) {
- $this->assertConditions(
- array( # expected
- #0 => "rc_timestamp >= '20110223000000'",
- 'rc_bot' => 0,
- 1 => sprintf( "(rc_namespace != '%s' AND rc_namespace != '%s')", $ns1, $ns2 ),
- ),
- array(
- 'namespace' => $ns1,
- 'associated' => 1,
- 'invert' => 1,
- ),
- "rc conditions with namespace inverted"
- );
- }
-
- /**
- * Provides associated namespaces to test recent changes
- * namespaces association filtering.
- */
- public function provideNamespacesAssociations() {
- return array( # (NS => Associated_NS)
- array( NS_MAIN, NS_TALK),
- array( NS_TALK, NS_MAIN),
- );
- }
-
-}
-
-
diff --git a/tests/phpunit/includes/specials/SpecialSearchTest.php b/tests/phpunit/includes/specials/SpecialSearchTest.php
deleted file mode 100644
index 20e42a68..00000000
--- a/tests/phpunit/includes/specials/SpecialSearchTest.php
+++ /dev/null
@@ -1,116 +0,0 @@
- true, 'ns6' => true). NULL to use default options.
- * @param $userOptions Array User options to test with. For example array('searchNs5' => 1 );. NULL to use default options.
- * @param $expectedProfile An expected search profile name
- * @param $expectedNs Array Expected namespaces
- */
- function testProfileAndNamespaceLoading(
- $requested, $userOptions, $expectedProfile, $expectedNS,
- $message = 'Profile name and namespaces mismatches!'
- ) {
- $context = new RequestContext;
- $context->setUser(
- $this->newUserWithSearchNS( $userOptions )
- );
- /*
- $context->setRequest( new FauxRequest( array(
- 'ns5'=>true,
- 'ns6'=>true,
- ) ));
- */
- $context->setRequest( new FauxRequest( $requested ));
- $search = new SpecialSearch();
- $search->setContext( $context );
- $search->load();
-
- /**
- * Verify profile name and namespace in the same assertion to make
- * sure we will be able to fully compare the above code. PHPUnit stop
- * after an assertion fail.
- */
- $this->assertEquals(
- array( /** Expected: */
- 'ProfileName' => $expectedProfile,
- 'Namespaces' => $expectedNS,
- )
- , array( /** Actual: */
- 'ProfileName' => $search->getProfile(),
- 'Namespaces' => $search->getNamespaces(),
- )
- , $message
- );
-
- }
-
- function provideSearchOptionsTests() {
- $defaultNS = SearchEngine::defaultNamespaces();
- $EMPTY_REQUEST = array();
- $NO_USER_PREF = null;
-
- return array(
- /**
- * Parameters:
- * ,
- * Followed by expected values:
- * ,
- * Then an optional message.
- */
- array(
- $EMPTY_REQUEST, $NO_USER_PREF,
- 'default', $defaultNS,
- 'Bug 33270: No request nor user preferences should give default profile'
- ),
- array(
- array( 'ns5' => 1 ), $NO_USER_PREF,
- 'advanced', array( 5),
- 'Web request with specific NS should override user preference'
- ),
- array(
- $EMPTY_REQUEST, array( 'searchNs2' => 1, 'searchNs14' => 1 ),
- 'advanced', array( 2, 14 ),
- 'Bug 33583: search with no option should honor User search preferences'
- ),
- array(
- $EMPTY_REQUEST, array_fill_keys( array_map( function( $ns ) {
- return "searchNs$ns";
- }, $defaultNS ), 0 ) + array( 'searchNs2' => 1, 'searchNs14' => 1 ),
- 'advanced', array( 2, 14 ),
- 'Bug 33583: search with no option should honor User search preferences'
- . 'and have all other namespace disabled'
- ),
- );
- }
-
- /**
- * Helper to create a new User object with given options
- * User remains anonymous though
- */
- function newUserWithSearchNS( $opt = null ) {
- $u = User::newFromId(0);
- if( $opt === null ) {
- return $u;
- }
- foreach($opt as $name => $value) {
- $u->setOption( $name, $value );
- }
- return $u;
- }
-}
-
diff --git a/tests/phpunit/includes/upload/UploadFromUrlTest.php b/tests/phpunit/includes/upload/UploadFromUrlTest.php
deleted file mode 100644
index f66c387b..00000000
--- a/tests/phpunit/includes/upload/UploadFromUrlTest.php
+++ /dev/null
@@ -1,351 +0,0 @@
-exists() ) {
- $this->deleteFile( 'UploadFromUrlTest.png' );
- }
- }
-
- protected function doApiRequest( Array $params, Array $unused = null, $appendModule = false, User $user = null ) {
- $sessionId = session_id();
- session_write_close();
-
- $req = new FauxRequest( $params, true, $_SESSION );
- $module = new ApiMain( $req, true );
- $module->execute();
-
- wfSetupSession( $sessionId );
- return array( $module->getResultData(), $req );
- }
-
- /**
- * Ensure that the job queue is empty before continuing
- */
- public function testClearQueue() {
- $job = Job::pop();
- while ( $job ) {
- $job = Job::pop();
- }
- $this->assertFalse( $job );
- }
-
- /**
- * @todo Document why we test login, since the $wgUser hack used doesn't
- * require login
- */
- public function testLogin() {
- $data = $this->doApiRequest( array(
- 'action' => 'login',
- 'lgname' => $this->user->userName,
- 'lgpassword' => $this->user->passWord ) );
- $this->assertArrayHasKey( "login", $data[0] );
- $this->assertArrayHasKey( "result", $data[0]['login'] );
- $this->assertEquals( "NeedToken", $data[0]['login']['result'] );
- $token = $data[0]['login']['token'];
-
- $data = $this->doApiRequest( array(
- 'action' => 'login',
- "lgtoken" => $token,
- 'lgname' => $this->user->userName,
- 'lgpassword' => $this->user->passWord ) );
-
- $this->assertArrayHasKey( "login", $data[0] );
- $this->assertArrayHasKey( "result", $data[0]['login'] );
- $this->assertEquals( "Success", $data[0]['login']['result'] );
- $this->assertArrayHasKey( 'lgtoken', $data[0]['login'] );
-
- return $data;
- }
-
- /**
- * @depends testLogin
- * @depends testClearQueue
- */
- public function testSetupUrlDownload( $data ) {
- $token = $this->user->getEditToken();
- $exception = false;
-
- try {
- $this->doApiRequest( array(
- 'action' => 'upload',
- ) );
- } catch ( UsageException $e ) {
- $exception = true;
- $this->assertEquals( "The token parameter must be set", $e->getMessage() );
- }
- $this->assertTrue( $exception, "Got exception" );
-
- $exception = false;
- try {
- $this->doApiRequest( array(
- 'action' => 'upload',
- 'token' => $token,
- ), $data );
- } catch ( UsageException $e ) {
- $exception = true;
- $this->assertEquals( "One of the parameters sessionkey, file, url, statuskey is required",
- $e->getMessage() );
- }
- $this->assertTrue( $exception, "Got exception" );
-
- $exception = false;
- try {
- $this->doApiRequest( array(
- 'action' => 'upload',
- 'url' => 'http://www.example.com/test.png',
- 'token' => $token,
- ), $data );
- } catch ( UsageException $e ) {
- $exception = true;
- $this->assertEquals( "The filename parameter must be set", $e->getMessage() );
- }
- $this->assertTrue( $exception, "Got exception" );
-
- $this->user->removeGroup( 'sysop' );
- $exception = false;
- try {
- $this->doApiRequest( array(
- 'action' => 'upload',
- 'url' => 'http://www.example.com/test.png',
- 'filename' => 'UploadFromUrlTest.png',
- 'token' => $token,
- ), $data );
- } catch ( UsageException $e ) {
- $exception = true;
- $this->assertEquals( "Permission denied", $e->getMessage() );
- }
- $this->assertTrue( $exception, "Got exception" );
-
- $this->user->addGroup( 'sysop' );
- $data = $this->doApiRequest( array(
- 'action' => 'upload',
- 'url' => 'http://bits.wikimedia.org/skins-1.5/common/images/poweredby_mediawiki_88x31.png',
- 'asyncdownload' => 1,
- 'filename' => 'UploadFromUrlTest.png',
- 'token' => $token,
- ), $data );
-
- $this->assertEquals( $data[0]['upload']['result'], 'Queued', 'Queued upload' );
-
- $job = Job::pop();
- $this->assertThat( $job, $this->isInstanceOf( 'UploadFromUrlJob' ), 'Queued upload inserted' );
- }
-
- /**
- * @depends testLogin
- * @depends testClearQueue
- */
- public function testAsyncUpload( $data ) {
- $token = $this->user->getEditToken();
-
- $this->user->addGroup( 'users' );
-
- $data = $this->doAsyncUpload( $token, true );
- $this->assertEquals( $data[0]['upload']['result'], 'Success' );
- $this->assertEquals( $data[0]['upload']['filename'], 'UploadFromUrlTest.png' );
- $this->assertTrue( wfLocalFile( $data[0]['upload']['filename'] )->exists() );
-
- $this->deleteFile( 'UploadFromUrlTest.png' );
-
- return $data;
- }
-
- /**
- * @depends testLogin
- * @depends testClearQueue
- */
- public function testAsyncUploadWarning( $data ) {
- $token = $this->user->getEditToken();
-
- $this->user->addGroup( 'users' );
-
-
- $data = $this->doAsyncUpload( $token );
-
- $this->assertEquals( $data[0]['upload']['result'], 'Warning' );
- $this->assertTrue( isset( $data[0]['upload']['sessionkey'] ) );
-
- $data = $this->doApiRequest( array(
- 'action' => 'upload',
- 'sessionkey' => $data[0]['upload']['sessionkey'],
- 'filename' => 'UploadFromUrlTest.png',
- 'ignorewarnings' => 1,
- 'token' => $token,
- ) );
- $this->assertEquals( $data[0]['upload']['result'], 'Success' );
- $this->assertEquals( $data[0]['upload']['filename'], 'UploadFromUrlTest.png' );
- $this->assertTrue( wfLocalFile( $data[0]['upload']['filename'] )->exists() );
-
- $this->deleteFile( 'UploadFromUrlTest.png' );
-
- return $data;
- }
-
- /**
- * @depends testLogin
- * @depends testClearQueue
- */
- public function testSyncDownload( $data ) {
- $token = $this->user->getEditToken();
-
- $job = Job::pop();
- $this->assertFalse( $job, 'Starting with an empty jobqueue' );
-
- $this->user->addGroup( 'users' );
- $data = $this->doApiRequest( array(
- 'action' => 'upload',
- 'filename' => 'UploadFromUrlTest.png',
- 'url' => 'http://bits.wikimedia.org/skins-1.5/common/images/poweredby_mediawiki_88x31.png',
- 'ignorewarnings' => true,
- 'token' => $token,
- ), $data );
-
- $job = Job::pop();
- $this->assertFalse( $job );
-
- $this->assertEquals( 'Success', $data[0]['upload']['result'] );
- $this->deleteFile( 'UploadFromUrlTest.png' );
-
- return $data;
- }
-
- public function testLeaveMessage() {
- $token = $this->user->user->getEditToken();
-
- $talk = $this->user->user->getTalkPage();
- if ( $talk->exists() ) {
- $page = WikiPage::factory( $talk );
- $page->doDeleteArticle( '' );
- }
-
- $this->assertFalse( (bool)$talk->getArticleID( Title::GAID_FOR_UPDATE ), 'User talk does not exist' );
-
- $data = $this->doApiRequest( array(
- 'action' => 'upload',
- 'filename' => 'UploadFromUrlTest.png',
- 'url' => 'http://bits.wikimedia.org/skins-1.5/common/images/poweredby_mediawiki_88x31.png',
- 'asyncdownload' => 1,
- 'token' => $token,
- 'leavemessage' => 1,
- 'ignorewarnings' => 1,
- ) );
-
- $job = Job::pop();
- $this->assertEquals( 'UploadFromUrlJob', get_class( $job ) );
- $job->run();
-
- $this->assertTrue( wfLocalFile( 'UploadFromUrlTest.png' )->exists() );
- $this->assertTrue( (bool)$talk->getArticleID( Title::GAID_FOR_UPDATE ), 'User talk exists' );
-
- $this->deleteFile( 'UploadFromUrlTest.png' );
-
- $talkRev = Revision::newFromTitle( $talk );
- $talkSize = $talkRev->getSize();
-
- $exception = false;
- try {
- $data = $this->doApiRequest( array(
- 'action' => 'upload',
- 'filename' => 'UploadFromUrlTest.png',
- 'url' => 'http://bits.wikimedia.org/skins-1.5/common/images/poweredby_mediawiki_88x31.png',
- 'asyncdownload' => 1,
- 'token' => $token,
- 'leavemessage' => 1,
- ) );
- } catch ( UsageException $e ) {
- $exception = true;
- $this->assertEquals( 'Using leavemessage without ignorewarnings is not supported', $e->getMessage() );
- }
- $this->assertTrue( $exception );
-
- $job = Job::pop();
- $this->assertFalse( $job );
-
- return;
-
- /*
- // Broken until using leavemessage with ignorewarnings is supported
- $job->run();
-
- $this->assertFalse( wfLocalFile( 'UploadFromUrlTest.png' )->exists() );
-
- $talkRev = Revision::newFromTitle( $talk );
- $this->assertTrue( $talkRev->getSize() > $talkSize, 'New message left' );
- */
- }
-
- /**
- * Helper function to perform an async upload, execute the job and fetch
- * the status
- *
- * @return array The result of action=upload&statuskey=key
- */
- private function doAsyncUpload( $token, $ignoreWarnings = false, $leaveMessage = false ) {
- $params = array(
- 'action' => 'upload',
- 'filename' => 'UploadFromUrlTest.png',
- 'url' => 'http://bits.wikimedia.org/skins-1.5/common/images/poweredby_mediawiki_88x31.png',
- 'asyncdownload' => 1,
- 'token' => $token,
- );
- if ( $ignoreWarnings ) {
- $params['ignorewarnings'] = 1;
- }
- if ( $leaveMessage ) {
- $params['leavemessage'] = 1;
- }
-
- $data = $this->doApiRequest( $params );
- $this->assertEquals( $data[0]['upload']['result'], 'Queued' );
- $this->assertTrue( isset( $data[0]['upload']['statuskey'] ) );
- $statusKey = $data[0]['upload']['statuskey'];
-
- $job = Job::pop();
- $this->assertEquals( 'UploadFromUrlJob', get_class( $job ) );
-
- $status = $job->run();
- $this->assertTrue( $status );
-
- $data = $this->doApiRequest( array(
- 'action' => 'upload',
- 'statuskey' => $statusKey,
- 'token' => $token,
- ) );
-
- return $data;
- }
-
-
- /**
- *
- */
- protected function deleteFile( $name ) {
- $t = Title::newFromText( $name, NS_FILE );
- $this->assertTrue($t->exists(), "File '$name' exists");
-
- if ( $t->exists() ) {
- $file = wfFindFile( $name, array( 'ignoreRedirect' => true ) );
- $empty = "";
- FileDeleteForm::doDelete( $t, $file, $empty, "none", true );
- $page = WikiPage::factory( $t );
- $page->doDeleteArticle( "testing" );
- }
- $t = Title::newFromText( $name, NS_FILE );
-
- $this->assertFalse($t->exists(), "File '$name' was deleted");
- }
- }
diff --git a/tests/phpunit/includes/upload/UploadStashTest.php b/tests/phpunit/includes/upload/UploadStashTest.php
deleted file mode 100644
index 66fafaaf..00000000
--- a/tests/phpunit/includes/upload/UploadStashTest.php
+++ /dev/null
@@ -1,77 +0,0 @@
-bug29408File = __DIR__ . '/bug29408';
- file_put_contents( $this->bug29408File, "\x00" );
-
- self::$users = array(
- 'sysop' => new TestUser(
- 'Uploadstashtestsysop',
- 'Upload Stash Test Sysop',
- 'upload_stash_test_sysop@example.com',
- array( 'sysop' )
- ),
- 'uploader' => new TestUser(
- 'Uploadstashtestuser',
- 'Upload Stash Test User',
- 'upload_stash_test_user@example.com',
- array()
- )
- );
- }
-
- public function testBug29408() {
- global $wgUser;
- $wgUser = self::$users['uploader']->user;
-
- $repo = RepoGroup::singleton()->getLocalRepo();
- $stash = new UploadStash( $repo );
-
- // Throws exception caught by PHPUnit on failure
- $file = $stash->stashFile( $this->bug29408File );
- // We'll never reach this point if we hit bug 29408
- $this->assertTrue( true, 'Unrecognized file without extension' );
-
- $stash->removeFile( $file->getFileKey() );
- }
-
- public function testValidRequest() {
- $request = new FauxRequest( array( 'wpFileKey' => 'foo') );
- $this->assertFalse( UploadFromStash::isValidRequest($request), 'Check failure on bad wpFileKey' );
-
- $request = new FauxRequest( array( 'wpSessionKey' => 'foo') );
- $this->assertFalse( UploadFromStash::isValidRequest($request), 'Check failure on bad wpSessionKey' );
-
- $request = new FauxRequest( array( 'wpFileKey' => 'testkey-test.test') );
- $this->assertTrue( UploadFromStash::isValidRequest($request), 'Check good wpFileKey' );
-
- $request = new FauxRequest( array( 'wpFileKey' => 'testkey-test.test') );
- $this->assertTrue( UploadFromStash::isValidRequest($request), 'Check good wpSessionKey' );
-
- $request = new FauxRequest( array( 'wpFileKey' => 'testkey-test.test', 'wpSessionKey' => 'foo') );
- $this->assertTrue( UploadFromStash::isValidRequest($request), 'Check key precedence' );
- }
-
- public function tearDown() {
- parent::tearDown();
-
- if( file_exists( $this->bug29408File . "." ) ) {
- unlink( $this->bug29408File . "." );
- }
-
- if( file_exists( $this->bug29408File ) ) {
- unlink( $this->bug29408File );
- }
- }
-}
diff --git a/tests/phpunit/includes/upload/UploadTest.php b/tests/phpunit/includes/upload/UploadTest.php
deleted file mode 100644
index 6948f5b1..00000000
--- a/tests/phpunit/includes/upload/UploadTest.php
+++ /dev/null
@@ -1,141 +0,0 @@
-upload = new UploadTestHandler;
- $this->hooks = $wgHooks;
- $wgHooks['InterwikiLoadPrefix'][] = function( $prefix, &$data ) {
- return false;
- };
- }
-
- function tearDown() {
- global $wgHooks;
- $wgHooks = $this->hooks;
- }
-
-
- /**
- * First checks the return code
- * of UploadBase::getTitle() and then the actual returned title
- *
- * @dataProvider dataTestTitleValidation
- */
- public function testTitleValidation( $srcFilename, $dstFilename, $code, $msg ) {
- /* Check the result code */
- $this->assertEquals( $code,
- $this->upload->testTitleValidation( $srcFilename ),
- "$msg code" );
-
- /* If we expect a valid title, check the title itself. */
- if ( $code == UploadBase::OK ) {
- $this->assertEquals( $dstFilename,
- $this->upload->getTitle()->getText(),
- "$msg text" );
- }
- }
-
- /**
- * Test various forms of valid and invalid titles that can be supplied.
- */
- public function dataTestTitleValidation() {
- return array(
- /* Test a valid title */
- array( 'ValidTitle.jpg', 'ValidTitle.jpg', UploadBase::OK,
- 'upload valid title' ),
- /* A title with a slash */
- array( 'A/B.jpg', 'B.jpg', UploadBase::OK,
- 'upload title with slash' ),
- /* A title with illegal char */
- array( 'A:B.jpg', 'A-B.jpg', UploadBase::OK,
- 'upload title with colon' ),
- /* Stripping leading File: prefix */
- array( 'File:C.jpg', 'C.jpg', UploadBase::OK,
- 'upload title with File prefix' ),
- /* Test illegal suggested title (r94601) */
- array( '%281%29.JPG', null, UploadBase::ILLEGAL_FILENAME,
- 'illegal title for upload' ),
- /* A title without extension */
- array( 'A', null, UploadBase::FILETYPE_MISSING,
- 'upload title without extension' ),
- /* A title with no basename */
- array( '.jpg', null, UploadBase::MIN_LENGTH_PARTNAME,
- 'upload title without basename' ),
- /* A title that is longer than 255 bytes */
- array( str_repeat( 'a', 255 ) . '.jpg', null, UploadBase::FILENAME_TOO_LONG,
- 'upload title longer than 255 bytes' ),
- /* A title that is longer than 240 bytes */
- array( str_repeat( 'a', 240 ) . '.jpg', null, UploadBase::FILENAME_TOO_LONG,
- 'upload title longer than 240 bytes' ),
- );
- }
-
- /**
- * Test the upload verification functions
- */
- public function testVerifyUpload() {
- /* Setup with zero file size */
- $this->upload->initializePathInfo( '', '', 0 );
- $result = $this->upload->verifyUpload();
- $this->assertEquals( UploadBase::EMPTY_FILE,
- $result['status'],
- 'upload empty file' );
- }
-
- // Helper used to create an empty file of size $size.
- private function createFileOfSize( $size ) {
- $filename = tempnam( wfTempDir(), "mwuploadtest" );
-
- $fh = fopen( $filename, 'w' );
- ftruncate( $fh, $size );
- fclose( $fh );
-
- return $filename;
- }
-
- /**
- * test uploading a 100 bytes file with $wgMaxUploadSize = 100
- *
- * This method should be abstracted so we can test different settings.
- */
-
- public function testMaxUploadSize() {
- global $wgMaxUploadSize;
- $savedGlobal = $wgMaxUploadSize; // save global
- global $wgFileExtensions;
- $wgFileExtensions[] = 'txt';
-
- $wgMaxUploadSize = 100;
-
- $filename = $this->createFileOfSize( $wgMaxUploadSize );
- $this->upload->initializePathInfo( basename($filename) . '.txt', $filename, 100 );
- $result = $this->upload->verifyUpload();
- unlink( $filename );
-
- $this->assertEquals(
- array( 'status' => UploadBase::OK ), $result );
-
- $wgMaxUploadSize = $savedGlobal; // restore global
- }
-}
-
-class UploadTestHandler extends UploadBase {
- public function initializeFromRequest( &$request ) { }
- public function testTitleValidation( $name ) {
- $this->mTitle = false;
- $this->mDesiredDestName = $name;
- $this->mTitleError = UploadBase::OK;
- $this->getTitle();
- return $this->mTitleError;
- }
-
-
-}
diff --git a/tests/phpunit/install-phpunit.sh b/tests/phpunit/install-phpunit.sh
deleted file mode 100644
index 2d2b53ab..00000000
--- a/tests/phpunit/install-phpunit.sh
+++ /dev/null
@@ -1,36 +0,0 @@
-#!/bin/sh
-
-has_binary () {
- if [ -z `which $1` ]; then
- return 1
- fi
- return 0
-}
-
-if [ `id -u` -ne 0 ]; then
- echo '*** ERROR' Must be root to run
- exit 1
-fi
-
-if ( has_binary phpunit ); then
- echo PHPUnit already installed
-else if ( has_binary pear ); then
- echo Installing phpunit with pear
- pear channel-discover pear.phpunit.de
- pear channel-discover components.ez.no
- pear channel-discover pear.symfony-project.com
- pear install phpunit/PHPUnit
-else if ( has_binary apt-get ); then
- echo Installing phpunit with apt-get
- apt-get install phpunit
-else if ( has_binary yum ); then
- echo Installing phpunit with yum
- yum install phpunit
-else if ( has_binary port ); then
- echo Installing phpunit with macports
- port install php5-unit
-fi
-fi
-fi
-fi
-fi
diff --git a/tests/phpunit/languages/LanguageAmTest.php b/tests/phpunit/languages/LanguageAmTest.php
deleted file mode 100644
index 3a648ded..00000000
--- a/tests/phpunit/languages/LanguageAmTest.php
+++ /dev/null
@@ -1,33 +0,0 @@
-lang = Language::factory( 'Am' );
- }
- function tearDown() {
- unset( $this->lang );
- }
-
- /** @dataProvider providePlural */
- function testPlural( $result, $value ) {
- $forms = array( 'one', 'other' );
- $this->assertEquals( $result, $this->lang->convertPlural( $value, $forms ) );
- }
-
- function providePlural() {
- return array (
- array( 'one', 0 ),
- array( 'one', 1 ),
- array( 'other', 2 ),
- array( 'other', 200 ),
- );
- }
-}
diff --git a/tests/phpunit/languages/LanguageArTest.php b/tests/phpunit/languages/LanguageArTest.php
deleted file mode 100644
index b23e0534..00000000
--- a/tests/phpunit/languages/LanguageArTest.php
+++ /dev/null
@@ -1,78 +0,0 @@
-lang = Language::factory( 'Ar' );
- }
- function tearDown() {
- unset( $this->lang );
- }
-
- function testFormatNum() {
- $this->assertEquals( '١٬٢٣٤٬٥٦٧', $this->lang->formatNum( '1234567' ) );
- $this->assertEquals( '-١٢٫٨٩', $this->lang->formatNum( -12.89 ) );
- }
-
- /**
- * Mostly to test the raw ascii feature.
- * @dataProvider providerSprintfDate
- */
- function testSprintfDate( $format, $date, $expected ) {
- $this->assertEquals( $expected, $this->lang->sprintfDate( $format, $date ) );
- }
-
- function providerSprintfDate() {
- return array(
- array(
- 'xg "vs" g',
- '20120102030410',
- 'يناير vs ٣'
- ),
- array(
- 'xmY',
- '20120102030410',
- '١٤٣٣'
- ),
- array(
- 'xnxmY',
- '20120102030410',
- '1433'
- ),
- array(
- 'xN xmj xmn xN xmY',
- '20120102030410',
- ' 7 2 ١٤٣٣'
- ),
- );
- }
- /** @dataProvider providePlural */
- function testPlural( $result, $value ) {
- $forms = array( 'zero', 'one', 'two', 'few', 'many', 'other' );
- $this->assertEquals( $result, $this->lang->convertPlural( $value, $forms ) );
- }
- function providePlural() {
- return array (
- array( 'zero', 0 ),
- array( 'one', 1 ),
- array( 'two', 2 ),
- array( 'few', 3 ),
- array( 'few', 9 ),
- array( 'few', 110 ),
- array( 'many', 11 ),
- array( 'many', 15 ),
- array( 'many', 99 ),
- array( 'many', 9999 ),
- array( 'other', 100 ),
- array( 'other', 102 ),
- array( 'other', 1000 ),
- array( 'other', 1.7 ),
- );
- }
-}
diff --git a/tests/phpunit/languages/LanguageBeTest.php b/tests/phpunit/languages/LanguageBeTest.php
deleted file mode 100644
index 735ccc63..00000000
--- a/tests/phpunit/languages/LanguageBeTest.php
+++ /dev/null
@@ -1,40 +0,0 @@
-lang = Language::factory( 'Be' );
- }
- function tearDown() {
- unset( $this->lang );
- }
-
- /** @dataProvider providePlural */
- function testPlural( $result, $value ) {
- $forms = array( 'one', 'few', 'many', 'other' );
- $this->assertEquals( $result, $this->lang->convertPlural( $value, $forms ) );
- }
-
- function providePlural() {
- return array (
- array( 'one', 1 ),
- array( 'many', 11 ),
- array( 'one', 91 ),
- array( 'one', 121 ),
- array( 'few', 2 ),
- array( 'few', 3 ),
- array( 'few', 4 ),
- array( 'few', 334 ),
- array( 'many', 5 ),
- array( 'many', 15 ),
- array( 'many', 120 ),
- );
- }
-}
diff --git a/tests/phpunit/languages/LanguageBe_taraskTest.php b/tests/phpunit/languages/LanguageBe_taraskTest.php
deleted file mode 100644
index 765cdb8f..00000000
--- a/tests/phpunit/languages/LanguageBe_taraskTest.php
+++ /dev/null
@@ -1,65 +0,0 @@
-lang = Language::factory( 'Be-tarask' );
- }
- function tearDown() {
- unset( $this->lang );
- }
-
- /** see bug 23156 & r64981 */
- function testSearchRightSingleQuotationMarkAsApostroph() {
- $this->assertEquals(
- "'",
- $this->lang->normalizeForSearch( '’' ),
- 'bug 23156: U+2019 conversion to U+0027'
- );
- }
- /** see bug 23156 & r64981 */
- function testCommafy() {
- $this->assertEquals( '1,234,567', $this->lang->commafy( '1234567' ) );
- $this->assertEquals( '12,345', $this->lang->commafy( '12345' ) );
- }
- /** see bug 23156 & r64981 */
- function testDoesNotCommafyFourDigitsNumber() {
- $this->assertEquals( '1234', $this->lang->commafy( '1234' ) );
- }
- /** @dataProvider providePluralFourForms */
- function testPluralFourForms( $result, $value ) {
- $forms = array( 'one', 'few', 'many', 'other' );
- $this->assertEquals( $result, $this->lang->convertPlural( $value, $forms ) );
- }
-
- function providePluralFourForms() {
- return array (
- array( 'one', 1 ),
- array( 'many', 11 ),
- array( 'one', 91 ),
- array( 'one', 121 ),
- array( 'few', 2 ),
- array( 'few', 3 ),
- array( 'few', 4 ),
- array( 'few', 334 ),
- array( 'many', 5 ),
- array( 'many', 15 ),
- array( 'many', 120 ),
- );
- }
- /** @dataProvider providePluralTwoForms */
- function testPluralTwoForms( $result, $value ) {
- $forms = array( 'one', 'several' );
- $this->assertEquals( $result, $this->lang->convertPlural( $value, $forms ) );
- }
- function providePluralTwoForms() {
- return array (
- array( 'one', 1 ),
- array( 'several', 11 ),
- array( 'several', 91 ),
- array( 'several', 121 ),
- );
- }
-
-}
diff --git a/tests/phpunit/languages/LanguageBhTest.php b/tests/phpunit/languages/LanguageBhTest.php
deleted file mode 100644
index e1e2a13e..00000000
--- a/tests/phpunit/languages/LanguageBhTest.php
+++ /dev/null
@@ -1,34 +0,0 @@
-lang = Language::factory( 'Bh' );
- }
- function tearDown() {
- unset( $this->lang );
- }
-
- /** @dataProvider providePlural */
- function testPlural( $result, $value ) {
- $forms = array( 'one', 'other' );
- $this->assertEquals( $result, $this->lang->convertPlural( $value, $forms ) );
- }
-
- function providePlural() {
- return array (
- array( 'one', 0 ),
- array( 'one', 1 ),
- array( 'other', 2 ),
- array( 'other', 200 ),
- );
- }
-
-}
diff --git a/tests/phpunit/languages/LanguageBsTest.php b/tests/phpunit/languages/LanguageBsTest.php
deleted file mode 100644
index b6631c03..00000000
--- a/tests/phpunit/languages/LanguageBsTest.php
+++ /dev/null
@@ -1,41 +0,0 @@
-lang = Language::factory( 'Bs' );
- }
- function tearDown() {
- unset( $this->lang );
- }
-
- /** @dataProvider providePlural */
- function testPlural( $result, $value ) {
- $forms = array( 'one', 'few', 'many', 'other' );
- $this->assertEquals( $result, $this->lang->convertPlural( $value, $forms ) );
- }
-
- function providePlural() {
- return array (
- array( 'many', 0 ),
- array( 'one', 1 ),
- array( 'few', 2 ),
- array( 'few', 4 ),
- array( 'many', 5 ),
- array( 'many', 11 ),
- array( 'many', 20 ),
- array( 'one', 21 ),
- array( 'few', 24 ),
- array( 'many', 25 ),
- array( 'many', 200 ),
- );
- }
-
-}
diff --git a/tests/phpunit/languages/LanguageCsTest.php b/tests/phpunit/languages/LanguageCsTest.php
deleted file mode 100644
index dda29f9a..00000000
--- a/tests/phpunit/languages/LanguageCsTest.php
+++ /dev/null
@@ -1,40 +0,0 @@
-lang = Language::factory( 'cs' );
- }
- function tearDown() {
- unset( $this->lang );
- }
-
- /** @dataProvider providerPlural */
- function testPlural( $result, $value ) {
- $forms = array( 'one', 'few', 'other' );
- $this->assertEquals( $result, $this->lang->convertPlural( $value, $forms ) );
- }
-
- function providerPlural() {
- return array (
- array( 'other', 0 ),
- array( 'one', 1 ),
- array( 'few', 2 ),
- array( 'few', 3 ),
- array( 'few', 4 ),
- array( 'other', 5 ),
- array( 'other', 11 ),
- array( 'other', 20 ),
- array( 'other', 25 ),
- array( 'other', 200 ),
- );
- }
-
-}
diff --git a/tests/phpunit/languages/LanguageCuTest.php b/tests/phpunit/languages/LanguageCuTest.php
deleted file mode 100644
index f8186d7b..00000000
--- a/tests/phpunit/languages/LanguageCuTest.php
+++ /dev/null
@@ -1,41 +0,0 @@
-lang = Language::factory( 'cu' );
- }
- function tearDown() {
- unset( $this->lang );
- }
-
- /** @dataProvider providerPlural */
- function testPlural( $result, $value ) {
- $forms = array( 'one', 'few', 'many', 'other' );
- $this->assertEquals( $result, $this->lang->convertPlural( $value, $forms ) );
- }
-
- function providerPlural() {
- return array (
- array( 'other', 0 ),
- array( 'one', 1 ),
- array( 'few', 2 ),
- array( 'many', 3 ),
- array( 'many', 4 ),
- array( 'other', 5 ),
- array( 'one', 11 ),
- array( 'other', 20 ),
- array( 'few', 22 ),
- array( 'many', 223 ),
- array( 'other', 200 ),
- );
- }
-
-}
diff --git a/tests/phpunit/languages/LanguageCyTest.php b/tests/phpunit/languages/LanguageCyTest.php
deleted file mode 100644
index e9f9e410..00000000
--- a/tests/phpunit/languages/LanguageCyTest.php
+++ /dev/null
@@ -1,42 +0,0 @@
-lang = Language::factory( 'cy' );
- }
- function tearDown() {
- unset( $this->lang );
- }
-
- /** @dataProvider providerPlural */
- function testPlural( $result, $value ) {
- $forms = array( 'zero', 'one', 'two', 'few', 'many', 'other' );
- $this->assertEquals( $result, $this->lang->convertPlural( $value, $forms ) );
- }
-
- function providerPlural() {
- return array (
- array( 'zero', 0 ),
- array( 'one', 1 ),
- array( 'two', 2 ),
- array( 'few', 3 ),
- array( 'many', 6 ),
- array( 'other', 4 ),
- array( 'other', 5 ),
- array( 'other', 11 ),
- array( 'other', 20 ),
- array( 'other', 22 ),
- array( 'other', 223 ),
- array( 'other', 200.00 ),
- );
- }
-
-}
diff --git a/tests/phpunit/languages/LanguageDsbTest.php b/tests/phpunit/languages/LanguageDsbTest.php
deleted file mode 100644
index ab7f9313..00000000
--- a/tests/phpunit/languages/LanguageDsbTest.php
+++ /dev/null
@@ -1,40 +0,0 @@
-lang = Language::factory( 'dsb' );
- }
- function tearDown() {
- unset( $this->lang );
- }
-
- /** @dataProvider providePlural */
- function testPlural( $result, $value ) {
- $forms = array( 'one', 'two', 'few', 'other' );
- $this->assertEquals( $result, $this->lang->convertPlural( $value, $forms ) );
- }
-
- function providePlural() {
- return array (
- array( 'other', 0 ),
- array( 'one', 1 ),
- array( 'one', 101 ),
- array( 'one', 90001 ),
- array( 'two', 2 ),
- array( 'few', 3 ),
- array( 'few', 203 ),
- array( 'few', 4 ),
- array( 'other', 99 ),
- array( 'other', 555 ),
- );
- }
-
-}
diff --git a/tests/phpunit/languages/LanguageFrTest.php b/tests/phpunit/languages/LanguageFrTest.php
deleted file mode 100644
index 8538744e..00000000
--- a/tests/phpunit/languages/LanguageFrTest.php
+++ /dev/null
@@ -1,34 +0,0 @@
-lang = Language::factory( 'fr' );
- }
- function tearDown() {
- unset( $this->lang );
- }
-
- /** @dataProvider providePlural */
- function testPlural( $result, $value ) {
- $forms = array( 'one', 'other' );
- $this->assertEquals( $result, $this->lang->convertPlural( $value, $forms ) );
- }
-
- function providePlural() {
- return array (
- array( 'one', 0 ),
- array( 'one', 1 ),
- array( 'other', 2 ),
- array( 'other', 200 ),
- );
- }
-
-}
diff --git a/tests/phpunit/languages/LanguageGaTest.php b/tests/phpunit/languages/LanguageGaTest.php
deleted file mode 100644
index fbd9f11d..00000000
--- a/tests/phpunit/languages/LanguageGaTest.php
+++ /dev/null
@@ -1,34 +0,0 @@
-lang = Language::factory( 'ga' );
- }
- function tearDown() {
- unset( $this->lang );
- }
-
- /** @dataProvider providerPlural */
- function testPlural( $result, $value ) {
- $forms = array( 'one', 'two', 'other' );
- $this->assertEquals( $result, $this->lang->convertPlural( $value, $forms ) );
- }
-
- function providerPlural() {
- return array (
- array( 'other', 0 ),
- array( 'one', 1 ),
- array( 'two', 2 ),
- array( 'other', 200 ),
- );
- }
-
-}
diff --git a/tests/phpunit/languages/LanguageGdTest.php b/tests/phpunit/languages/LanguageGdTest.php
deleted file mode 100644
index 24574bda..00000000
--- a/tests/phpunit/languages/LanguageGdTest.php
+++ /dev/null
@@ -1,38 +0,0 @@
-lang = Language::factory( 'gd' );
- }
- function tearDown() {
- unset( $this->lang );
- }
-
- /** @dataProvider providerPlural */
- function testPlural( $result, $value ) {
- // The CLDR ticket for this plural forms is not same as mw plural forms. See http://unicode.org/cldr/trac/ticket/2883
- $forms = array( 'Form 1', 'Form 2', 'Form 3', 'Form 4', 'Form 5', 'Form 6' );
- $this->assertEquals( $result, $this->lang->convertPlural( $value, $forms ) );
- }
- function providerPlural() {
- return array (
- array( 'Form 6', 0 ),
- array( 'Form 1', 1 ),
- array( 'Form 2', 2 ),
- array( 'Form 3', 11 ),
- array( 'Form 4', 12 ),
- array( 'Form 5', 3 ),
- array( 'Form 5', 19 ),
- array( 'Form 6', 200 ),
- );
- }
-
-}
diff --git a/tests/phpunit/languages/LanguageGvTest.php b/tests/phpunit/languages/LanguageGvTest.php
deleted file mode 100644
index 3d298b9b..00000000
--- a/tests/phpunit/languages/LanguageGvTest.php
+++ /dev/null
@@ -1,39 +0,0 @@
-lang = Language::factory( 'gv' );
- }
- function tearDown() {
- unset( $this->lang );
- }
-
- /** @dataProvider providerPlural */
- function testPlural( $result, $value ) {
- // This is not compatible with CLDR plural rules http://unicode.org/repos/cldr-tmp/trunk/diff/supplemental/language_plural_rules.html#gv
- $forms = array( 'Form 1', 'Form 2', 'Form 3', 'Form 4' );
- $this->assertEquals( $result, $this->lang->convertPlural( $value, $forms ) );
- }
- function providerPlural() {
- return array (
- array( 'Form 4', 0 ),
- array( 'Form 2', 1 ),
- array( 'Form 3', 2 ),
- array( 'Form 4', 3 ),
- array( 'Form 1', 20 ),
- array( 'Form 2', 21 ),
- array( 'Form 3', 22 ),
- array( 'Form 4', 23 ),
- array( 'Form 4', 50 ),
- );
- }
-
-}
diff --git a/tests/phpunit/languages/LanguageHeTest.php b/tests/phpunit/languages/LanguageHeTest.php
deleted file mode 100644
index 7833da71..00000000
--- a/tests/phpunit/languages/LanguageHeTest.php
+++ /dev/null
@@ -1,48 +0,0 @@
-lang = Language::factory( 'he' );
- }
- function tearDown() {
- unset( $this->lang );
- }
-
- /** @dataProvider providerPluralDual */
- function testPluralDual( $result, $value ) {
- $forms = array( 'one', 'two', 'other' );
- $this->assertEquals( $result, $this->lang->convertPlural( $value, $forms ) );
- }
-
- function providerPluralDual() {
- return array (
- array( 'other', 0 ), // Zero -> plural
- array( 'one', 1 ), // Singular
- array( 'two', 2 ), // Dual
- array( 'other', 3 ), // Plural
- );
- }
-
- /** @dataProvider providerPlural */
- function testPlural( $result, $value ) {
- $forms = array( 'one', 'other' );
- $this->assertEquals( $result, $this->lang->convertPlural( $value, $forms ) );
- }
-
- function providerPlural() {
- return array (
- array( 'other', 0 ), // Zero -> plural
- array( 'one', 1 ), // Singular
- array( 'other', 2 ), // Plural, no dual provided
- array( 'other', 3 ), // Plural
- );
- }
-}
diff --git a/tests/phpunit/languages/LanguageHiTest.php b/tests/phpunit/languages/LanguageHiTest.php
deleted file mode 100644
index ead9e020..00000000
--- a/tests/phpunit/languages/LanguageHiTest.php
+++ /dev/null
@@ -1,34 +0,0 @@
-lang = Language::factory( 'Hi' );
- }
- function tearDown() {
- unset( $this->lang );
- }
-
- /** @dataProvider providePlural */
- function testPlural( $result, $value ) {
- $forms = array( 'one', 'other' );
- $this->assertEquals( $result, $this->lang->convertPlural( $value, $forms ) );
- }
-
- function providePlural() {
- return array (
- array( 'one', 0 ),
- array( 'one', 1 ),
- array( 'other', 2 ),
- array( 'other', 200 ),
- );
- }
-
-}
diff --git a/tests/phpunit/languages/LanguageHrTest.php b/tests/phpunit/languages/LanguageHrTest.php
deleted file mode 100644
index 4f1c66bf..00000000
--- a/tests/phpunit/languages/LanguageHrTest.php
+++ /dev/null
@@ -1,41 +0,0 @@
-lang = Language::factory( 'hr' );
- }
- function tearDown() {
- unset( $this->lang );
- }
-
- /** @dataProvider providerPlural */
- function testPlural( $result, $value ) {
- $forms = array( 'one', 'few', 'many', 'other' );
- $this->assertEquals( $result, $this->lang->convertPlural( $value, $forms ) );
- }
-
- function providerPlural() {
- return array (
- array( 'many', 0 ),
- array( 'one', 1 ),
- array( 'few', 2 ),
- array( 'few', 4 ),
- array( 'many', 5 ),
- array( 'many', 11 ),
- array( 'many', 20 ),
- array( 'one', 21 ),
- array( 'few', 24 ),
- array( 'many', 25 ),
- array( 'many', 200 ),
- );
- }
-
-}
diff --git a/tests/phpunit/languages/LanguageHsbTest.php b/tests/phpunit/languages/LanguageHsbTest.php
deleted file mode 100644
index 803c7721..00000000
--- a/tests/phpunit/languages/LanguageHsbTest.php
+++ /dev/null
@@ -1,40 +0,0 @@
-lang = Language::factory( 'hsb' );
- }
- function tearDown() {
- unset( $this->lang );
- }
-
- /** @dataProvider providePlural */
- function testPlural( $result, $value ) {
- $forms = array( 'one', 'two', 'few', 'other' );
- $this->assertEquals( $result, $this->lang->convertPlural( $value, $forms ) );
- }
-
- function providePlural() {
- return array (
- array( 'other', 0 ),
- array( 'one', 1 ),
- array( 'one', 101 ),
- array( 'one', 90001 ),
- array( 'two', 2 ),
- array( 'few', 3 ),
- array( 'few', 203 ),
- array( 'few', 4 ),
- array( 'other', 99 ),
- array( 'other', 555 ),
- );
- }
-
-}
diff --git a/tests/phpunit/languages/LanguageHuTest.php b/tests/phpunit/languages/LanguageHuTest.php
deleted file mode 100644
index adbd37ec..00000000
--- a/tests/phpunit/languages/LanguageHuTest.php
+++ /dev/null
@@ -1,34 +0,0 @@
-lang = Language::factory( 'Hu' );
- }
- function tearDown() {
- unset( $this->lang );
- }
-
- /** @dataProvider providePlural */
- function testPlural( $result, $value ) {
- $forms = array( 'one', 'other' );
- $this->assertEquals( $result, $this->lang->convertPlural( $value, $forms ) );
- }
-
- function providePlural() {
- return array (
- array( 'other', 0 ),
- array( 'one', 1 ),
- array( 'other', 2 ),
- array( 'other', 200 ),
- );
- }
-
-}
diff --git a/tests/phpunit/languages/LanguageHyTest.php b/tests/phpunit/languages/LanguageHyTest.php
deleted file mode 100644
index 7990bdfc..00000000
--- a/tests/phpunit/languages/LanguageHyTest.php
+++ /dev/null
@@ -1,34 +0,0 @@
-lang = Language::factory( 'hy' );
- }
- function tearDown() {
- unset( $this->lang );
- }
-
- /** @dataProvider providerPlural */
- function testPlural( $result, $value ) {
- $forms = array( 'one', 'other' );
- $this->assertEquals( $result, $this->lang->convertPlural( $value, $forms ) );
- }
-
- function providerPlural() {
- return array (
- array( 'one', 0 ),
- array( 'one', 1 ),
- array( 'other', 2 ),
- array( 'other', 200 ),
- );
- }
-
-}
diff --git a/tests/phpunit/languages/LanguageKshTest.php b/tests/phpunit/languages/LanguageKshTest.php
deleted file mode 100644
index ab889464..00000000
--- a/tests/phpunit/languages/LanguageKshTest.php
+++ /dev/null
@@ -1,34 +0,0 @@
-lang = Language::factory( 'ksh' );
- }
- function tearDown() {
- unset( $this->lang );
- }
-
- /** @dataProvider providerPlural */
- function testPlural( $result, $value ) {
- $forms = array( 'one', 'other', 'zero' );
- $this->assertEquals( $result, $this->lang->convertPlural( $value, $forms ) );
- }
-
- function providerPlural() {
- return array (
- array( 'zero', 0 ),
- array( 'one', 1 ),
- array( 'other', 2 ),
- array( 'other', 200 ),
- );
- }
-
-}
diff --git a/tests/phpunit/languages/LanguageLnTest.php b/tests/phpunit/languages/LanguageLnTest.php
deleted file mode 100644
index 0fd9167e..00000000
--- a/tests/phpunit/languages/LanguageLnTest.php
+++ /dev/null
@@ -1,34 +0,0 @@
-lang = Language::factory( 'ln' );
- }
- function tearDown() {
- unset( $this->lang );
- }
-
- /** @dataProvider providePlural */
- function testPlural( $result, $value ) {
- $forms = array( 'one', 'other' );
- $this->assertEquals( $result, $this->lang->convertPlural( $value, $forms ) );
- }
-
- function providePlural() {
- return array (
- array( 'one', 0 ),
- array( 'one', 1 ),
- array( 'other', 2 ),
- array( 'other', 200 ),
- );
- }
-
-}
diff --git a/tests/phpunit/languages/LanguageLtTest.php b/tests/phpunit/languages/LanguageLtTest.php
deleted file mode 100644
index 0d7c7d3e..00000000
--- a/tests/phpunit/languages/LanguageLtTest.php
+++ /dev/null
@@ -1,53 +0,0 @@
-lang = Language::factory( 'Lt' );
- }
- function tearDown() {
- unset( $this->lang );
- }
-
- /** @dataProvider provideOneFewOtherCases */
- function testOneFewOtherPlural( $result, $value ) {
- $forms = array( 'one', 'few', 'other' );
- $this->assertEquals( $result, $this->lang->convertPlural( $value, $forms ) );
- }
-
- /** @dataProvider provideOneFewCases */
- function testOneFewPlural( $result, $value ) {
- $forms = array( 'one', 'few' );
- $this->assertEquals( $result, $this->lang->convertPlural( $value, $forms ) );
- }
-
- function provideOneFewOtherCases() {
- return array (
- array( 'other', 0 ),
- array( 'one', 1 ),
- array( 'few', 2 ),
- array( 'few', 9 ),
- array( 'other', 10 ),
- array( 'other', 11 ),
- array( 'other', 20 ),
- array( 'one', 21 ),
- array( 'few', 32 ),
- array( 'one', 41 ),
- array( 'one', 40001 ),
- );
- }
-
- function provideOneFewCases() {
- return array (
- array( 'one', 1 ),
- array( 'few', 15 ),
- );
- }
-}
diff --git a/tests/phpunit/languages/LanguageLvTest.php b/tests/phpunit/languages/LanguageLvTest.php
deleted file mode 100644
index 0636da5f..00000000
--- a/tests/phpunit/languages/LanguageLvTest.php
+++ /dev/null
@@ -1,39 +0,0 @@
-lang = Language::factory( 'lv' );
- }
- function tearDown() {
- unset( $this->lang );
- }
-
- /** @dataProvider providerPlural */
- function testPlural( $result, $value ) {
- $forms = array( 'one', 'other' );
- $this->assertEquals( $result, $this->lang->convertPlural( $value, $forms ) );
- }
-
- function providerPlural() {
- return array (
- array( 'other', 0 ), #this must be zero form as per CLDR
- array( 'one', 1 ),
- array( 'other', 11 ),
- array( 'one', 21 ),
- array( 'other', 411 ),
- array( 'other', 12.345 ),
- array( 'other', 20 ),
- array( 'one', 31 ),
- array( 'other', 200 ),
- );
- }
-
-}
diff --git a/tests/phpunit/languages/LanguageMgTest.php b/tests/phpunit/languages/LanguageMgTest.php
deleted file mode 100644
index 06b56547..00000000
--- a/tests/phpunit/languages/LanguageMgTest.php
+++ /dev/null
@@ -1,35 +0,0 @@
-lang = Language::factory( 'mg' );
- }
- function tearDown() {
- unset( $this->lang );
- }
-
- /** @dataProvider providePlural */
- function testPlural( $result, $value ) {
- $forms = array( 'one', 'other' );
- $this->assertEquals( $result, $this->lang->convertPlural( $value, $forms ) );
- }
-
- function providePlural() {
- return array (
- array( 'one', 0 ),
- array( 'one', 1 ),
- array( 'other', 2 ),
- array( 'other', 200 ),
- array( 'other', 123.3434 ),
- );
- }
-
-}
diff --git a/tests/phpunit/languages/LanguageMkTest.php b/tests/phpunit/languages/LanguageMkTest.php
deleted file mode 100644
index cf5ec3d9..00000000
--- a/tests/phpunit/languages/LanguageMkTest.php
+++ /dev/null
@@ -1,41 +0,0 @@
-lang = Language::factory( 'mk' );
- }
- function tearDown() {
- unset( $this->lang );
- }
-
- /** @dataProvider providerPlural */
- function testPlural( $result, $value ) {
- $forms = array( 'one', 'other' );
- $this->assertEquals( $result, $this->lang->convertPlural( $value, $forms ) );
- }
-
-
- function providerPlural() {
- return array (
- array( 'other', 0 ),
- array( 'one', 1 ),
- array( 'other', 11 ),
- array( 'one', 21 ),
- array( 'other', 411 ),
- array( 'other', 12.345 ),
- array( 'other', 20 ),
- array( 'one', 31 ),
- array( 'other', 200 ),
- );
- }
-
-
-}
diff --git a/tests/phpunit/languages/LanguageMlTest.php b/tests/phpunit/languages/LanguageMlTest.php
deleted file mode 100644
index 8c4b0b2f..00000000
--- a/tests/phpunit/languages/LanguageMlTest.php
+++ /dev/null
@@ -1,43 +0,0 @@
-lang = Language::factory( 'Ml' );
- }
- function tearDown() {
- unset( $this->lang );
- }
-
- /** see bug 29495 */
- /** @dataProvider providerFormatNum*/
- function testFormatNum( $result, $value ) {
- $this->assertEquals( $result, $this->lang->formatNum( $value ) );
- }
-
- function providerFormatNum() {
- return array(
- array( '12,34,567', '1234567' ),
- array( '12,345', '12345' ),
- array( '1', '1' ),
- array( '123', '123' ) ,
- array( '1,234', '1234' ),
- array( '12,345.56', '12345.56' ),
- array( '12,34,56,79,81,23,45,678', '12345679812345678' ),
- array( '.12345', '.12345' ),
- array( '-12,00,000', '-1200000' ),
- array( '-98', '-98' ),
- array( '-98', -98 ),
- array( '-1,23,45,678', -12345678 ),
- array( '', '' ),
- array( '', null ),
- );
- }
-}
diff --git a/tests/phpunit/languages/LanguageMoTest.php b/tests/phpunit/languages/LanguageMoTest.php
deleted file mode 100644
index 533e590f..00000000
--- a/tests/phpunit/languages/LanguageMoTest.php
+++ /dev/null
@@ -1,43 +0,0 @@
-lang = Language::factory( 'mo' );
- }
- function tearDown() {
- unset( $this->lang );
- }
-
- /** @dataProvider providerPlural */
- function testPlural( $result, $value ) {
- $forms = array( 'one', 'few', 'other' );
- $this->assertEquals( $result, $this->lang->convertPlural( $value, $forms ) );
- }
-
- function providerPlural() {
- return array (
- array( 'few', 0 ),
- array( 'one', 1 ),
- array( 'few', 2 ),
- array( 'few', 19 ),
- array( 'other', 20 ),
- array( 'other', 99 ),
- array( 'other', 100 ),
- array( 'few', 101 ),
- array( 'few', 119 ),
- array( 'other', 120 ),
- array( 'other', 200 ),
- array( 'few', 201 ),
- array( 'few', 219 ),
- array( 'other', 220 ),
- );
- }
-}
diff --git a/tests/phpunit/languages/LanguageMtTest.php b/tests/phpunit/languages/LanguageMtTest.php
deleted file mode 100644
index 421bb388..00000000
--- a/tests/phpunit/languages/LanguageMtTest.php
+++ /dev/null
@@ -1,72 +0,0 @@
-lang = Language::factory( 'mt' );
- }
- function tearDown() {
- unset( $this->lang );
- }
-
- /** @dataProvider providerPluralAllForms */
- function testPluralAllForms( $result, $value ) {
- $forms = array( 'one', 'few', 'many', 'other' );
- $this->assertEquals( $result, $this->lang->convertPlural( $value, $forms ) );
- }
-
- function providerPluralAllForms() {
- return array (
- array( 'few', 0 ),
- array( 'one', 1 ),
- array( 'few', 2 ),
- array( 'few', 10 ),
- array( 'many', 11 ),
- array( 'many', 19 ),
- array( 'other', 20 ),
- array( 'other', 99 ),
- array( 'other', 100 ),
- array( 'other', 101 ),
- array( 'few', 102 ),
- array( 'few', 110 ),
- array( 'many', 111 ),
- array( 'many', 119 ),
- array( 'other', 120 ),
- array( 'other', 201 ),
- );
- }
-
- /** @dataProvider providerPluralTwoForms */
- function testPluralTwoForms( $result, $value ) {
- $forms = array( 'one', 'many' );
- $this->assertEquals( $result, $this->lang->convertPlural( $value, $forms ) );
- }
-
- function providerPluralTwoForms() {
- return array (
- array( 'many', 0 ),
- array( 'one', 1 ),
- array( 'many', 2 ),
- array( 'many', 10 ),
- array( 'many', 11 ),
- array( 'many', 19 ),
- array( 'many', 20 ),
- array( 'many', 99 ),
- array( 'many', 100 ),
- array( 'many', 101 ),
- array( 'many', 102 ),
- array( 'many', 110 ),
- array( 'many', 111 ),
- array( 'many', 119 ),
- array( 'many', 120 ),
- array( 'many', 201 ),
- );
- }
-}
diff --git a/tests/phpunit/languages/LanguageNlTest.php b/tests/phpunit/languages/LanguageNlTest.php
deleted file mode 100644
index cf979cd2..00000000
--- a/tests/phpunit/languages/LanguageNlTest.php
+++ /dev/null
@@ -1,28 +0,0 @@
-lang = Language::factory( 'Nl' );
- }
- function tearDown() {
- unset( $this->lang );
- }
-
- function testFormatNum() {
- $this->assertEquals( '1.234.567', $this->lang->formatNum( '1234567' ) );
- $this->assertEquals( '12.345', $this->lang->formatNum( '12345' ) );
- $this->assertEquals( '1', $this->lang->formatNum( '1' ) );
- $this->assertEquals( '123', $this->lang->formatNum( '123' ) );
- $this->assertEquals( '1.234', $this->lang->formatNum( '1234' ) );
- $this->assertEquals( '12.345,56', $this->lang->formatNum( '12345.56' ) );
- $this->assertEquals( ',1234556', $this->lang->formatNum( '.1234556' ) );
- }
-}
diff --git a/tests/phpunit/languages/LanguageNsoTest.php b/tests/phpunit/languages/LanguageNsoTest.php
deleted file mode 100644
index ea393628..00000000
--- a/tests/phpunit/languages/LanguageNsoTest.php
+++ /dev/null
@@ -1,32 +0,0 @@
-lang = Language::factory( 'nso' );
- }
- function tearDown() {
- unset( $this->lang );
- }
-
- /** @dataProvider providerPlural */
- function testPlural( $result, $value ) {
- $forms = array( 'one', 'many' );
- $this->assertEquals( $result, $this->lang->convertPlural( $value, $forms ) );
- }
-
- function providerPlural() {
- return array (
- array( 'one', 0 ),
- array( 'one', 1 ),
- array( 'many', 2 ),
- );
- }
-}
diff --git a/tests/phpunit/languages/LanguagePlTest.php b/tests/phpunit/languages/LanguagePlTest.php
deleted file mode 100644
index e56d4b77..00000000
--- a/tests/phpunit/languages/LanguagePlTest.php
+++ /dev/null
@@ -1,72 +0,0 @@
-lang = Language::factory( 'pl' );
- }
- function tearDown() {
- unset( $this->lang );
- }
-
- /** @dataProvider providerPluralFourForms */
- function testPluralFourForms( $result, $value ) {
- $forms = array( 'one', 'few', 'many' );
- $this->assertEquals( $result, $this->lang->convertPlural( $value, $forms ) );
- }
-
- function providerPluralFourForms() {
- return array (
- array( 'many', 0 ),
- array( 'one', 1 ),
- array( 'few', 2 ),
- array( 'few', 3 ),
- array( 'few', 4 ),
- array( 'many', 5 ),
- array( 'many', 9 ),
- array( 'many', 10 ),
- array( 'many', 11 ),
- array( 'many', 21 ),
- array( 'few', 22 ),
- array( 'few', 23 ),
- array( 'few', 24 ),
- array( 'many', 25 ),
- array( 'many', 200 ),
- array( 'many', 201 ),
- );
- }
-
- /** @dataProvider providerPlural */
- function testPlural( $result, $value ) {
- $forms = array( 'one', 'many' );
- $this->assertEquals( $result, $this->lang->convertPlural( $value, $forms ) );
- }
-
- function providerPlural() {
- return array (
- array( 'many', 0 ),
- array( 'one', 1 ),
- array( 'many', 2 ),
- array( 'many', 3 ),
- array( 'many', 4 ),
- array( 'many', 5 ),
- array( 'many', 9 ),
- array( 'many', 10 ),
- array( 'many', 11 ),
- array( 'many', 21 ),
- array( 'many', 22 ),
- array( 'many', 23 ),
- array( 'many', 24 ),
- array( 'many', 25 ),
- array( 'many', 200 ),
- array( 'many', 201 ),
- );
- }
-}
diff --git a/tests/phpunit/languages/LanguageRoTest.php b/tests/phpunit/languages/LanguageRoTest.php
deleted file mode 100644
index 5270f6fe..00000000
--- a/tests/phpunit/languages/LanguageRoTest.php
+++ /dev/null
@@ -1,43 +0,0 @@
-lang = Language::factory( 'ro' );
- }
- function tearDown() {
- unset( $this->lang );
- }
-
- /** @dataProvider providerPlural */
- function testPlural( $result, $value ) {
- $forms = array( 'one', 'few', 'other' );
- $this->assertEquals( $result, $this->lang->convertPlural( $value, $forms ) );
- }
-
- function providerPlural() {
- return array (
- array( 'few', 0 ),
- array( 'one', 1 ),
- array( 'few', 2 ),
- array( 'few', 19 ),
- array( 'other', 20 ),
- array( 'other', 99 ),
- array( 'other', 100 ),
- array( 'few', 101 ),
- array( 'few', 119 ),
- array( 'other', 120 ),
- array( 'other', 200 ),
- array( 'few', 201 ),
- array( 'few', 219 ),
- array( 'other', 220 ),
- );
- }
-}
diff --git a/tests/phpunit/languages/LanguageRuTest.php b/tests/phpunit/languages/LanguageRuTest.php
deleted file mode 100644
index 7a1f193b..00000000
--- a/tests/phpunit/languages/LanguageRuTest.php
+++ /dev/null
@@ -1,54 +0,0 @@
-lang = Language::factory( 'ru' );
- }
- function tearDown() {
- unset( $this->lang );
- }
-
- /** @dataProvider providePluralFourForms */
- function testPluralFourForms( $result, $value ) {
- $forms = array( 'one', 'few', 'many', 'other' );
- $this->assertEquals( $result, $this->lang->convertPlural( $value, $forms ) );
- }
-
- function providePluralFourForms() {
- return array (
- array( 'one', 1 ),
- array( 'many', 11 ),
- array( 'one', 91 ),
- array( 'one', 121 ),
- array( 'few', 2 ),
- array( 'few', 3 ),
- array( 'few', 4 ),
- array( 'few', 334 ),
- array( 'many', 5 ),
- array( 'many', 15 ),
- array( 'many', 120 ),
- );
- }
- /** @dataProvider providePluralTwoForms */
- function testPluralTwoForms( $result, $value ) {
- $forms = array( 'one', 'several' );
- $this->assertEquals( $result, $this->lang->convertPlural( $value, $forms ) );
- }
- function providePluralTwoForms() {
- return array (
- array( 'one', 1 ),
- array( 'several', 11 ),
- array( 'several', 91 ),
- array( 'several', 121 ),
- );
- }
-}
diff --git a/tests/phpunit/languages/LanguageSeTest.php b/tests/phpunit/languages/LanguageSeTest.php
deleted file mode 100644
index 065ec29e..00000000
--- a/tests/phpunit/languages/LanguageSeTest.php
+++ /dev/null
@@ -1,48 +0,0 @@
-lang = Language::factory( 'se' );
- }
- function tearDown() {
- unset( $this->lang );
- }
-
- /** @dataProvider providerPluralThreeForms */
- function testPluralThreeForms( $result, $value ) {
- $forms = array( 'one', 'two', 'other' );
- $this->assertEquals( $result, $this->lang->convertPlural( $value, $forms ) );
- }
-
- function providerPluralThreeForms() {
- return array (
- array( 'other', 0 ),
- array( 'one', 1 ),
- array( 'two', 2 ),
- array( 'other', 3 ),
- );
- }
-
- /** @dataProvider providerPlural */
- function testPlural( $result, $value ) {
- $forms = array( 'one', 'other' );
- $this->assertEquals( $result, $this->lang->convertPlural( $value, $forms ) );
- }
-
- function providerPlural() {
- return array (
- array( 'other', 0 ),
- array( 'one', 1 ),
- array( 'other', 2 ),
- array( 'other', 3 ),
- );
- }
-}
diff --git a/tests/phpunit/languages/LanguageSgsTest.php b/tests/phpunit/languages/LanguageSgsTest.php
deleted file mode 100644
index 931c82f0..00000000
--- a/tests/phpunit/languages/LanguageSgsTest.php
+++ /dev/null
@@ -1,66 +0,0 @@
-lang = Language::factory( 'Sgs' );
- }
- function tearDown() {
- unset( $this->lang );
- }
-
- /** @dataProvider providePluralAllForms */
- function testPluralAllForms( $result, $value ) {
- $forms = array( 'one', 'few', 'many', 'other' );
- $this->assertEquals( $result, $this->lang->convertPlural( $value, $forms ) );
- }
-
- function providePluralAllForms() {
- return array (
- array( 'many', 0 ),
- array( 'one', 1 ),
- array( 'few', 2 ),
- array( 'other', 3 ),
- array( 'many', 10 ),
- array( 'many', 11 ),
- array( 'many', 12 ),
- array( 'many', 19 ),
- array( 'other', 20 ),
- array( 'many', 100 ),
- array( 'one', 101 ),
- array( 'many', 111 ),
- array( 'many', 112 ),
- );
- }
-
- /** @dataProvider providePluralTwoForms */
- function testPluralTwoForms( $result, $value ) {
- $forms = array( 'one', 'other' );
- $this->assertEquals( $result, $this->lang->convertPlural( $value, $forms ) );
- }
-
- function providePluralTwoForms() {
- return array (
- array( 'other', 0 ),
- array( 'one', 1 ),
- array( 'other', 2 ),
- array( 'other', 3 ),
- array( 'other', 10 ),
- array( 'other', 11 ),
- array( 'other', 12 ),
- array( 'other', 19 ),
- array( 'other', 20 ),
- array( 'other', 100 ),
- array( 'one', 101 ),
- array( 'other', 111 ),
- array( 'other', 112 ),
- );
- }
-}
diff --git a/tests/phpunit/languages/LanguageShTest.php b/tests/phpunit/languages/LanguageShTest.php
deleted file mode 100644
index b8169aed..00000000
--- a/tests/phpunit/languages/LanguageShTest.php
+++ /dev/null
@@ -1,32 +0,0 @@
-lang = Language::factory( 'sh' );
- }
- function tearDown() {
- unset( $this->lang );
- }
-
- /** @dataProvider providerPlural */
- function testPlural( $result, $value ) {
- $forms = array( 'one', 'many' );
- $this->assertEquals( $result, $this->lang->convertPlural( $value, $forms ) );
- }
-
- function providerPlural() {
- return array (
- array( 'many', 0 ),
- array( 'one', 1 ),
- array( 'many', 2 ),
- );
- }
-}
diff --git a/tests/phpunit/languages/LanguageSkTest.php b/tests/phpunit/languages/LanguageSkTest.php
deleted file mode 100644
index 4cfd840e..00000000
--- a/tests/phpunit/languages/LanguageSkTest.php
+++ /dev/null
@@ -1,40 +0,0 @@
-lang = Language::factory( 'sk' );
- }
- function tearDown() {
- unset( $this->lang );
- }
-
- /** @dataProvider providerPlural */
- function testPlural( $result, $value ) {
- $forms = array( 'one', 'few', 'other' );
- $this->assertEquals( $result, $this->lang->convertPlural( $value, $forms ) );
- }
-
- function providerPlural() {
- return array (
- array( 'other', 0 ),
- array( 'one', 1 ),
- array( 'few', 2 ),
- array( 'few', 3 ),
- array( 'few', 4 ),
- array( 'other', 5 ),
- array( 'other', 11 ),
- array( 'other', 20 ),
- array( 'other', 25 ),
- array( 'other', 200 ),
- );
- }
-}
diff --git a/tests/phpunit/languages/LanguageSlTest.php b/tests/phpunit/languages/LanguageSlTest.php
deleted file mode 100644
index c1f75691..00000000
--- a/tests/phpunit/languages/LanguageSlTest.php
+++ /dev/null
@@ -1,42 +0,0 @@
-lang = Language::factory( 'sl' );
- }
- function tearDown() {
- unset( $this->lang );
- }
-
- /** @dataProvider providerPlural */
- function testPlural( $result, $value ) {
- $forms = array( 'one', 'two', 'few', 'other', 'zero' );
- $this->assertEquals( $result, $this->lang->convertPlural( $value, $forms ) );
- }
-
- function providerPlural() {
- return array (
- array( 'zero', 0 ),
- array( 'one', 1 ),
- array( 'two', 2 ),
- array( 'few', 3 ),
- array( 'few', 4 ),
- array( 'other', 5 ),
- array( 'other', 99 ),
- array( 'other', 100 ),
- array( 'one', 101 ),
- array( 'two', 102 ),
- array( 'few', 103 ),
- array( 'one', 201 ),
- );
- }
-}
diff --git a/tests/phpunit/languages/LanguageSmaTest.php b/tests/phpunit/languages/LanguageSmaTest.php
deleted file mode 100644
index b7e72e97..00000000
--- a/tests/phpunit/languages/LanguageSmaTest.php
+++ /dev/null
@@ -1,48 +0,0 @@
-lang = Language::factory( 'sma' );
- }
- function tearDown() {
- unset( $this->lang );
- }
-
- /** @dataProvider providerPluralThreeForms */
- function testPluralThreeForms( $result, $value ) {
- $forms = array( 'one', 'two', 'other' );
- $this->assertEquals( $result, $this->lang->convertPlural( $value, $forms ) );
- }
-
- function providerPluralThreeForms() {
- return array (
- array( 'other', 0 ),
- array( 'one', 1 ),
- array( 'two', 2 ),
- array( 'other', 3 ),
- );
- }
-
- /** @dataProvider providerPlural */
- function testPlural( $result, $value ) {
- $forms = array( 'one', 'other' );
- $this->assertEquals( $result, $this->lang->convertPlural( $value, $forms ) );
- }
-
- function providerPlural() {
- return array (
- array( 'other', 0 ),
- array( 'one', 1 ),
- array( 'other', 2 ),
- array( 'other', 3 ),
- );
- }
-}
diff --git a/tests/phpunit/languages/LanguageSrTest.php b/tests/phpunit/languages/LanguageSrTest.php
deleted file mode 100644
index d44ecf8e..00000000
--- a/tests/phpunit/languages/LanguageSrTest.php
+++ /dev/null
@@ -1,223 +0,0 @@
-
- * @copyright Copyright © 2011, Antoine Musso
- * @file
- */
-
-require_once dirname( __DIR__ ) . '/bootstrap.php';
-
-/** Tests for MediaWiki languages/LanguageSr.php */
-class LanguageSrTest extends MediaWikiTestCase {
- /* Language object. Initialized before each test */
- private $lang;
-
- function setUp() {
- $this->lang = Language::factory( 'sr' );
- }
- function tearDown() {
- unset( $this->lang );
- }
-
- ##### TESTS #######################################################
-
- function testEasyConversions( ) {
- $this->assertCyrillic(
- 'шђчћжШЂЧЋЖ',
- 'Cyrillic guessing characters'
- );
- $this->assertLatin(
- 'šđč枊ĐČĆŽ',
- 'Latin guessing characters'
- );
- }
-
- function testMixedConversions() {
- $this->assertCyrillic(
- 'шђчћжШЂЧЋЖ - šđčćž',
- 'Mostly cyrillic characters'
- );
- $this->assertLatin(
- 'šđč枊ĐČĆŽ - шђчћж',
- 'Mostly latin characters'
- );
- }
-
- function testSameAmountOfLatinAndCyrillicGetConverted() {
- $this->assertConverted(
- '4 latin: šđčć | 4 cyrillic: шђчћ',
- 'sr-ec'
- );
- $this->assertConverted(
- '4 latin: šđčć | 4 cyrillic: шђчћ',
- 'sr-el'
- );
- }
-
- /**
- * @author Nikola Smolenski
- */
- function testConversionToCyrillic() {
- //A simple convertion of Latin to Cyrillic
- $this->assertEquals( 'абвг',
- $this->convertToCyrillic( 'abvg' )
- );
- //Same as above, but assert that -{}-s must be removed and not converted
- $this->assertEquals( 'ljабnjвгdž',
- $this->convertToCyrillic( '-{lj}-ab-{nj}-vg-{dž}-' )
- );
- //A simple convertion of Cyrillic to Cyrillic
- $this->assertEquals( 'абвг',
- $this->convertToCyrillic( 'абвг' )
- );
- //Same as above, but assert that -{}-s must be removed and not converted
- $this->assertEquals( 'ljабnjвгdž',
- $this->convertToCyrillic( '-{lj}-аб-{nj}-вг-{dž}-' )
- );
- //This text has some Latin, but is recognized as Cyrillic, so it should not be converted
- $this->assertEquals( 'abvgшђжчћ',
- $this->convertToCyrillic( 'abvgшђжчћ' )
- );
- //Same as above, but assert that -{}-s must be removed
- $this->assertEquals( 'љabvgњшђжчћџ',
- $this->convertToCyrillic( '-{љ}-abvg-{њ}-шђжчћ-{џ}-' )
- );
- //This text has some Cyrillic, but is recognized as Latin, so it should be converted
- $this->assertEquals( 'абвгшђжчћ',
- $this->convertToCyrillic( 'абвгšđžčć' )
- );
- //Same as above, but assert that -{}-s must be removed and not converted
- $this->assertEquals( 'ljабвгnjшђжчћdž',
- $this->convertToCyrillic( '-{lj}-абвг-{nj}-šđžčć-{dž}-' )
- );
- // Roman numerals are not converted
- $this->assertEquals( 'а I б II в III г IV шђжчћ',
- $this->convertToCyrillic( 'a I b II v III g IV šđžčć' )
- );
- }
-
- function testConversionToLatin() {
- //A simple convertion of Latin to Latin
- $this->assertEquals( 'abcd',
- $this->convertToLatin( 'abcd' )
- );
- //A simple convertion of Cyrillic to Latin
- $this->assertEquals( 'abcd',
- $this->convertToLatin( 'абцд' )
- );
- //This text has some Latin, but is recognized as Cyrillic, so it should be converted
- $this->assertEquals( 'abcdšđžčć',
- $this->convertToLatin( 'abcdшђжчћ' )
- );
- //This text has some Cyrillic, but is recognized as Latin, so it should not be converted
- $this->assertEquals( 'абцдšđžčć',
- $this->convertToLatin( 'абцдšđžčć' )
- );
- }
-
- /** @dataProvider providePluralFourForms */
- function testPluralFourForms( $result, $value ) {
- $forms = array( 'one', 'few', 'many', 'other' );
- $this->assertEquals( $result, $this->lang->convertPlural( $value, $forms ) );
- }
-
- function providePluralFourForms() {
- return array (
- array( 'one', 1 ),
- array( 'many', 11 ),
- array( 'one', 91 ),
- array( 'one', 121 ),
- array( 'few', 2 ),
- array( 'few', 3 ),
- array( 'few', 4 ),
- array( 'few', 334 ),
- array( 'many', 5 ),
- array( 'many', 15 ),
- array( 'many', 120 ),
- );
- }
- /** @dataProvider providePluralTwoForms */
- function testPluralTwoForms( $result, $value ) {
- $forms = array( 'one', 'several' );
- $this->assertEquals( $result, $this->lang->convertPlural( $value, $forms ) );
- }
- function providePluralTwoForms() {
- return array (
- array( 'one', 1 ),
- array( 'several', 11 ),
- array( 'several', 91 ),
- array( 'several', 121 ),
- );
- }
-
- ##### HELPERS #####################################################
- /**
- *Wrapper to verify text stay the same after applying conversion
- * @param $text string Text to convert
- * @param $variant string Language variant 'sr-ec' or 'sr-el'
- * @param $msg string Optional message
- */
- function assertUnConverted( $text, $variant, $msg = '' ) {
- $this->assertEquals(
- $text,
- $this->convertTo( $text, $variant ),
- $msg
- );
- }
- /**
- * Wrapper to verify a text is different once converted to a variant.
- * @param $text string Text to convert
- * @param $variant string Language variant 'sr-ec' or 'sr-el'
- * @param $msg string Optional message
- */
- function assertConverted( $text, $variant, $msg = '' ) {
- $this->assertNotEquals(
- $text,
- $this->convertTo( $text, $variant ),
- $msg
- );
- }
-
- /**
- * Verifiy the given Cyrillic text is not converted when using
- * using the cyrillic variant and converted to Latin when using
- * the Latin variant.
- */
- function assertCyrillic( $text, $msg = '' ) {
- $this->assertUnConverted( $text, 'sr-ec', $msg );
- $this->assertConverted( $text, 'sr-el', $msg );
- }
- /**
- * Verifiy the given Latin text is not converted when using
- * using the Latin variant and converted to Cyrillic when using
- * the Cyrillic variant.
- */
- function assertLatin( $text, $msg = '' ) {
- $this->assertUnConverted( $text, 'sr-el', $msg );
- $this->assertConverted( $text, 'sr-ec', $msg );
- }
-
-
- /** Wrapper for converter::convertTo() method*/
- function convertTo( $text, $variant ) {
- return $this
- ->lang
- ->mConverter
- ->convertTo(
- $text, $variant
- );
- }
- function convertToCyrillic( $text ) {
- return $this->convertTo( $text, 'sr-ec' );
- }
- function convertToLatin( $text ) {
- return $this->convertTo( $text, 'sr-el' );
- }
-}
diff --git a/tests/phpunit/languages/LanguageTest.php b/tests/phpunit/languages/LanguageTest.php
deleted file mode 100644
index 2fa3e292..00000000
--- a/tests/phpunit/languages/LanguageTest.php
+++ /dev/null
@@ -1,1069 +0,0 @@
-lang = Language::factory( 'en' );
- }
- function tearDown() {
- unset( $this->lang );
- }
-
- function testLanguageConvertDoubleWidthToSingleWidth() {
- $this->assertEquals(
- "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz",
- $this->lang->normalizeForSearch(
- "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"
- ),
- 'convertDoubleWidth() with the full alphabet and digits'
- );
- }
-
- /**
- * @dataProvider provideFormattableTimes
- */
- function testFormatTimePeriod( $seconds, $format, $expected, $desc ) {
- $this->assertEquals( $expected, $this->lang->formatTimePeriod( $seconds, $format ), $desc );
- }
-
- function provideFormattableTimes() {
- return array(
- array(
- 9.45,
- array(),
- '9.5 s',
- 'formatTimePeriod() rounding (<10s)'
- ),
- array(
- 9.45,
- array( 'noabbrevs' => true ),
- '9.5 seconds',
- 'formatTimePeriod() rounding (<10s)'
- ),
- array(
- 9.95,
- array(),
- '10 s',
- 'formatTimePeriod() rounding (<10s)'
- ),
- array(
- 9.95,
- array( 'noabbrevs' => true ),
- '10 seconds',
- 'formatTimePeriod() rounding (<10s)'
- ),
- array(
- 59.55,
- array(),
- '1 min 0 s',
- 'formatTimePeriod() rounding (<60s)'
- ),
- array(
- 59.55,
- array( 'noabbrevs' => true ),
- '1 minute 0 seconds',
- 'formatTimePeriod() rounding (<60s)'
- ),
- array(
- 119.55,
- array(),
- '2 min 0 s',
- 'formatTimePeriod() rounding (<1h)'
- ),
- array(
- 119.55,
- array( 'noabbrevs' => true ),
- '2 minutes 0 seconds',
- 'formatTimePeriod() rounding (<1h)'
- ),
- array(
- 3599.55,
- array(),
- '1 h 0 min 0 s',
- 'formatTimePeriod() rounding (<1h)'
- ),
- array(
- 3599.55,
- array( 'noabbrevs' => true ),
- '1 hour 0 minutes 0 seconds',
- 'formatTimePeriod() rounding (<1h)'
- ),
- array(
- 7199.55,
- array(),
- '2 h 0 min 0 s',
- 'formatTimePeriod() rounding (>=1h)'
- ),
- array(
- 7199.55,
- array( 'noabbrevs' => true ),
- '2 hours 0 minutes 0 seconds',
- 'formatTimePeriod() rounding (>=1h)'
- ),
- array(
- 7199.55,
- 'avoidseconds',
- '2 h 0 min',
- 'formatTimePeriod() rounding (>=1h), avoidseconds'
- ),
- array(
- 7199.55,
- array( 'avoid' => 'avoidseconds', 'noabbrevs' => true ),
- '2 hours 0 minutes',
- 'formatTimePeriod() rounding (>=1h), avoidseconds'
- ),
- array(
- 7199.55,
- 'avoidminutes',
- '2 h 0 min',
- 'formatTimePeriod() rounding (>=1h), avoidminutes'
- ),
- array(
- 7199.55,
- array( 'avoid' => 'avoidminutes', 'noabbrevs' => true ),
- '2 hours 0 minutes',
- 'formatTimePeriod() rounding (>=1h), avoidminutes'
- ),
- array(
- 172799.55,
- 'avoidseconds',
- '48 h 0 min',
- 'formatTimePeriod() rounding (=48h), avoidseconds'
- ),
- array(
- 172799.55,
- array( 'avoid' => 'avoidseconds', 'noabbrevs' => true ),
- '48 hours 0 minutes',
- 'formatTimePeriod() rounding (=48h), avoidseconds'
- ),
- array(
- 259199.55,
- 'avoidminutes',
- '3 d 0 h',
- 'formatTimePeriod() rounding (>48h), avoidminutes'
- ),
- array(
- 259199.55,
- array( 'avoid' => 'avoidminutes', 'noabbrevs' => true ),
- '3 days 0 hours',
- 'formatTimePeriod() rounding (>48h), avoidminutes'
- ),
- array(
- 176399.55,
- 'avoidseconds',
- '2 d 1 h 0 min',
- 'formatTimePeriod() rounding (>48h), avoidseconds'
- ),
- array(
- 176399.55,
- array( 'avoid' => 'avoidseconds', 'noabbrevs' => true ),
- '2 days 1 hour 0 minutes',
- 'formatTimePeriod() rounding (>48h), avoidseconds'
- ),
- array(
- 176399.55,
- 'avoidminutes',
- '2 d 1 h',
- 'formatTimePeriod() rounding (>48h), avoidminutes'
- ),
- array(
- 176399.55,
- array( 'avoid' => 'avoidminutes', 'noabbrevs' => true ),
- '2 days 1 hour',
- 'formatTimePeriod() rounding (>48h), avoidminutes'
- ),
- array(
- 259199.55,
- 'avoidseconds',
- '3 d 0 h 0 min',
- 'formatTimePeriod() rounding (>48h), avoidseconds'
- ),
- array(
- 259199.55,
- array( 'avoid' => 'avoidseconds', 'noabbrevs' => true ),
- '3 days 0 hours 0 minutes',
- 'formatTimePeriod() rounding (>48h), avoidseconds'
- ),
- array(
- 172801.55,
- 'avoidseconds',
- '2 d 0 h 0 min',
- 'formatTimePeriod() rounding, (>48h), avoidseconds'
- ),
- array(
- 172801.55,
- array( 'avoid' => 'avoidseconds', 'noabbrevs' => true ),
- '2 days 0 hours 0 minutes',
- 'formatTimePeriod() rounding, (>48h), avoidseconds'
- ),
- array(
- 176460.55,
- array(),
- '2 d 1 h 1 min 1 s',
- 'formatTimePeriod() rounding, recursion, (>48h)'
- ),
- array(
- 176460.55,
- array( 'noabbrevs' => true ),
- '2 days 1 hour 1 minute 1 second',
- 'formatTimePeriod() rounding, recursion, (>48h)'
- ),
- );
-
- }
-
- function testTruncate() {
- $this->assertEquals(
- "XXX",
- $this->lang->truncate( "1234567890", 0, 'XXX' ),
- 'truncate prefix, len 0, small ellipsis'
- );
-
- $this->assertEquals(
- "12345XXX",
- $this->lang->truncate( "1234567890", 8, 'XXX' ),
- 'truncate prefix, small ellipsis'
- );
-
- $this->assertEquals(
- "123456789",
- $this->lang->truncate( "123456789", 5, 'XXXXXXXXXXXXXXX' ),
- 'truncate prefix, large ellipsis'
- );
-
- $this->assertEquals(
- "XXX67890",
- $this->lang->truncate( "1234567890", -8, 'XXX' ),
- 'truncate suffix, small ellipsis'
- );
-
- $this->assertEquals(
- "123456789",
- $this->lang->truncate( "123456789", -5, 'XXXXXXXXXXXXXXX' ),
- 'truncate suffix, large ellipsis'
- );
- }
-
- /**
- * @dataProvider provideHTMLTruncateData()
- */
- function testTruncateHtml( $len, $ellipsis, $input, $expected ) {
- // Actual HTML...
- $this->assertEquals(
- $expected,
- $this->lang->truncateHTML( $input, $len, $ellipsis )
- );
- }
-
- /**
- * Array format is ($len, $ellipsis, $input, $expected)
- */
- function provideHTMLTruncateData() {
- return array(
- array( 0, 'XXX', "1234567890", "XXX" ),
- array( 8, 'XXX', "1234567890", "12345XXX" ),
- array( 5, 'XXXXXXXXXXXXXXX', '1234567890', "1234567890" ),
- array( 2, '***',
- '
',
- '
',
- ),
- array( 2, '***',
- '123456789
',
- '***
',
- ),
- array( 2, '***',
- ' 23456789
',
- '***
',
- ),
- array( 3, '***',
- '123456789
',
- '***
',
- ),
- array( 4, '***',
- '123456789
',
- '1***
',
- ),
- array( 5, '***',
- '123456789',
- '12***',
- ),
- array( 6, '***',
- '123456789
',
- '123***
',
- ),
- array( 6, '***',
- '12 456789
',
- '12 ***
',
- ),
- array( 7, '***',
- '123456
789',
- '1234***
',
- ),
- array( 8, '***',
- '123456789
',
- '12345***
',
- ),
- array( 9, '***',
- '',
- '',
- ),
- array( 10, '***',
- '123456789
',
- '123456789
',
- ),
- );
- }
-
- /**
- * Test Language::isValidBuiltInCode()
- * @dataProvider provideLanguageCodes
- */
- function testBuiltInCodeValidation( $code, $message = '' ) {
- $this->assertTrue(
- (bool) Language::isValidBuiltInCode( $code ),
- "validating code $code $message"
- );
- }
-
- function testBuiltInCodeValidationRejectUnderscore() {
- $this->assertFalse(
- (bool) Language::isValidBuiltInCode( 'be_tarask' ),
- "reject underscore in language code"
- );
- }
-
- function provideLanguageCodes() {
- return array(
- array( 'fr' , 'Two letters, minor case' ),
- array( 'EN' , 'Two letters, upper case' ),
- array( 'tyv' , 'Three letters' ),
- array( 'tokipona' , 'long language code' ),
- array( 'be-tarask', 'With dash' ),
- array( 'Zh-classical', 'Begin with upper case, dash' ),
- array( 'Be-x-old', 'With extension (two dashes)' ),
- );
- }
-
- /**
- * @dataProvider provideSprintfDateSamples
- */
- function testSprintfDate( $format, $ts, $expected, $msg ) {
- $this->assertEquals(
- $expected,
- $this->lang->sprintfDate( $format, $ts ),
- "sprintfDate('$format', '$ts'): $msg"
- );
- }
- /**
- * bug 33454. sprintfDate should always use UTC.
- * @dataProvider provideSprintfDateSamples
- */
- function testSprintfDateTZ( $format, $ts, $expected, $msg ) {
- $oldTZ = date_default_timezone_get();
- $res = date_default_timezone_set( 'Asia/Seoul' );
- if ( !$res ) {
- $this->markTestSkipped( "Error setting Timezone" );
- }
-
- $this->assertEquals(
- $expected,
- $this->lang->sprintfDate( $format, $ts ),
- "sprintfDate('$format', '$ts'): $msg"
- );
-
- date_default_timezone_set( $oldTZ );
- }
-
- function provideSprintfDateSamples() {
- return array(
- array(
- 'xiY',
- '20111212000000',
- '1390', // note because we're testing English locale we get Latin-standard digits
- 'Iranian calendar full year'
- ),
- array(
- 'xiy',
- '20111212000000',
- '90',
- 'Iranian calendar short year'
- ),
- array(
- 'o',
- '20120101235000',
- '2011',
- 'ISO 8601 (week) year'
- ),
- array(
- 'W',
- '20120101235000',
- '52',
- 'Week number'
- ),
- array(
- 'W',
- '20120102235000',
- '1',
- 'Week number'
- ),
- array(
- 'o-\\WW-N',
- '20091231235000',
- '2009-W53-4',
- 'leap week'
- ),
- // What follows is mostly copied from http://www.mediawiki.org/wiki/Help:Extension:ParserFunctions#.23time
- array(
- 'Y',
- '20120102090705',
- '2012',
- 'Full year'
- ),
- array(
- 'y',
- '20120102090705',
- '12',
- '2 digit year'
- ),
- array(
- 'L',
- '20120102090705',
- '1',
- 'Leap year'
- ),
- array(
- 'n',
- '20120102090705',
- '1',
- 'Month index, not zero pad'
- ),
- array(
- 'N',
- '20120102090705',
- '01',
- 'Month index. Zero pad'
- ),
- array(
- 'M',
- '20120102090705',
- 'Jan',
- 'Month abbrev'
- ),
- array(
- 'F',
- '20120102090705',
- 'January',
- 'Full month'
- ),
- array(
- 'xg',
- '20120102090705',
- 'January',
- 'Genitive month name (same in EN)'
- ),
- array(
- 'j',
- '20120102090705',
- '2',
- 'Day of month (not zero pad)'
- ),
- array(
- 'd',
- '20120102090705',
- '02',
- 'Day of month (zero-pad)'
- ),
- array(
- 'z',
- '20120102090705',
- '1',
- 'Day of year (zero-indexed)'
- ),
- array(
- 'D',
- '20120102090705',
- 'Mon',
- 'Day of week (abbrev)'
- ),
- array(
- 'l',
- '20120102090705',
- 'Monday',
- 'Full day of week'
- ),
- array(
- 'N',
- '20120101090705',
- '7',
- 'Day of week (Mon=1, Sun=7)'
- ),
- array(
- 'w',
- '20120101090705',
- '0',
- 'Day of week (Sun=0, Sat=6)'
- ),
- array(
- 'N',
- '20120102090705',
- '1',
- 'Day of week'
- ),
- array(
- 'a',
- '20120102090705',
- 'am',
- 'am vs pm'
- ),
- array(
- 'A',
- '20120102120000',
- 'PM',
- 'AM vs PM'
- ),
- array(
- 'a',
- '20120102000000',
- 'am',
- 'AM vs PM'
- ),
- array(
- 'g',
- '20120102090705',
- '9',
- '12 hour, not Zero'
- ),
- array(
- 'h',
- '20120102090705',
- '09',
- '12 hour, zero padded'
- ),
- array(
- 'G',
- '20120102090705',
- '9',
- '24 hour, not zero'
- ),
- array(
- 'H',
- '20120102090705',
- '09',
- '24 hour, zero'
- ),
- array(
- 'H',
- '20120102110705',
- '11',
- '24 hour, zero'
- ),
- array(
- 'i',
- '20120102090705',
- '07',
- 'Minutes'
- ),
- array(
- 's',
- '20120102090705',
- '05',
- 'seconds'
- ),
- array(
- 'U',
- '20120102090705',
- '1325495225',
- 'unix time'
- ),
- array(
- 't',
- '20120102090705',
- '31',
- 'Days in current month'
- ),
- array(
- 'c',
- '20120102090705',
- '2012-01-02T09:07:05+00:00',
- 'ISO 8601 timestamp'
- ),
- array(
- 'r',
- '20120102090705',
- 'Mon, 02 Jan 2012 09:07:05 +0000',
- 'RFC 5322'
- ),
- array(
- 'xmj xmF xmn xmY',
- '20120102090705',
- '7 Safar 2 1433',
- 'Islamic'
- ),
- array(
- 'xij xiF xin xiY',
- '20120102090705',
- '12 Dey 10 1390',
- 'Iranian'
- ),
- array(
- 'xjj xjF xjn xjY',
- '20120102090705',
- '7 Tevet 4 5772',
- 'Hebrew'
- ),
- array(
- 'xjt',
- '20120102090705',
- '29',
- 'Hebrew number of days in month'
- ),
- array(
- 'xjx',
- '20120102090705',
- 'Tevet',
- 'Hebrew genitive month name (No difference in EN)'
- ),
- array(
- 'xkY',
- '20120102090705',
- '2555',
- 'Thai year'
- ),
- array(
- 'xoY',
- '20120102090705',
- '101',
- 'Minguo'
- ),
- array(
- 'xtY',
- '20120102090705',
- '平成24',
- 'nengo'
- ),
- array(
- 'xrxkYY',
- '20120102090705',
- 'MMDLV2012',
- 'Roman numerals'
- ),
- array(
- 'xhxjYY',
- '20120102090705',
- 'ה\'תשע"ב2012',
- 'Hebrew numberals'
- ),
- array(
- 'xnY',
- '20120102090705',
- '2012',
- 'Raw numerals (doesn\'t mean much in EN)'
- ),
- array(
- '[[Y "(yea"\\r)]] \\"xx\\"',
- '20120102090705',
- '[[2012 (year)]] "x"',
- 'Various escaping'
- ),
-
- );
- }
-
- /**
- * @dataProvider provideFormatSizes
- */
- function testFormatSize( $size, $expected, $msg ) {
- $this->assertEquals(
- $expected,
- $this->lang->formatSize( $size ),
- "formatSize('$size'): $msg"
- );
- }
-
- function provideFormatSizes() {
- return array(
- array(
- 0,
- "0 B",
- "Zero bytes"
- ),
- array(
- 1024,
- "1 KB",
- "1 kilobyte"
- ),
- array(
- 1024 * 1024,
- "1 MB",
- "1,024 megabytes"
- ),
- array(
- 1024 * 1024 * 1024,
- "1 GB",
- "1 gigabytes"
- ),
- array(
- pow( 1024, 4 ),
- "1 TB",
- "1 terabyte"
- ),
- array(
- pow( 1024, 5 ),
- "1 PB",
- "1 petabyte"
- ),
- array(
- pow( 1024, 6 ),
- "1 EB",
- "1,024 exabyte"
- ),
- array(
- pow( 1024, 7 ),
- "1 ZB",
- "1 zetabyte"
- ),
- array(
- pow( 1024, 8 ),
- "1 YB",
- "1 yottabyte"
- ),
- // How big!? THIS BIG!
- );
- }
-
- /**
- * @dataProvider provideFormatBitrate
- */
- function testFormatBitrate( $bps, $expected, $msg ) {
- $this->assertEquals(
- $expected,
- $this->lang->formatBitrate( $bps ),
- "formatBitrate('$bps'): $msg"
- );
- }
-
- function provideFormatBitrate() {
- return array(
- array(
- 0,
- "0 bps",
- "0 bits per second"
- ),
- array(
- 999,
- "999 bps",
- "999 bits per second"
- ),
- array(
- 1000,
- "1 kbps",
- "1 kilobit per second"
- ),
- array(
- 1000 * 1000,
- "1 Mbps",
- "1 megabit per second"
- ),
- array(
- pow( 10, 9 ),
- "1 Gbps",
- "1 gigabit per second"
- ),
- array(
- pow( 10, 12 ),
- "1 Tbps",
- "1 terabit per second"
- ),
- array(
- pow( 10, 15 ),
- "1 Pbps",
- "1 petabit per second"
- ),
- array(
- pow( 10, 18 ),
- "1 Ebps",
- "1 exabit per second"
- ),
- array(
- pow( 10, 21 ),
- "1 Zbps",
- "1 zetabit per second"
- ),
- array(
- pow( 10, 24 ),
- "1 Ybps",
- "1 yottabit per second"
- ),
- array(
- pow( 10, 27 ),
- "1,000 Ybps",
- "1,000 yottabits per second"
- ),
- );
- }
-
-
-
- /**
- * @dataProvider provideFormatDuration
- */
- function testFormatDuration( $duration, $expected, $intervals = array() ) {
- $this->assertEquals(
- $expected,
- $this->lang->formatDuration( $duration, $intervals ),
- "formatDuration('$duration'): $expected"
- );
- }
-
- function provideFormatDuration() {
- return array(
- array(
- 0,
- '0 seconds',
- ),
- array(
- 1,
- '1 second',
- ),
- array(
- 2,
- '2 seconds',
- ),
- array(
- 60,
- '1 minute',
- ),
- array(
- 2 * 60,
- '2 minutes',
- ),
- array(
- 3600,
- '1 hour',
- ),
- array(
- 2 * 3600,
- '2 hours',
- ),
- array(
- 24 * 3600,
- '1 day',
- ),
- array(
- 2 * 86400,
- '2 days',
- ),
- array(
- 365.25 * 86400, // 365.25 * 86400 = 31557600
- '1 year',
- ),
- array(
- 2 * 31557600,
- '2 years',
- ),
- array(
- 10 * 31557600,
- '1 decade',
- ),
- array(
- 20 * 31557600,
- '2 decades',
- ),
- array(
- 100 * 31557600,
- '1 century',
- ),
- array(
- 200 * 31557600,
- '2 centuries',
- ),
- array(
- 1000 * 31557600,
- '1 millennium',
- ),
- array(
- 2000 * 31557600,
- '2 millennia',
- ),
- array(
- 9001,
- '2 hours, 30 minutes and 1 second'
- ),
- array(
- 3601,
- '1 hour and 1 second'
- ),
- array(
- 31557600 + 2 * 86400 + 9000,
- '1 year, 2 days, 2 hours and 30 minutes'
- ),
- array(
- 42 * 1000 * 31557600 + 42,
- '42 millennia and 42 seconds'
- ),
- array(
- 60,
- '60 seconds',
- array( 'seconds' ),
- ),
- array(
- 61,
- '61 seconds',
- array( 'seconds' ),
- ),
- array(
- 1,
- '1 second',
- array( 'seconds' ),
- ),
- array(
- 31557600 + 2 * 86400 + 9000,
- '1 year, 2 days and 150 minutes',
- array( 'years', 'days', 'minutes' ),
- ),
- array(
- 42,
- '0 days',
- array( 'years', 'days' ),
- ),
- array(
- 31557600 + 2 * 86400 + 9000,
- '1 year, 2 days and 150 minutes',
- array( 'minutes', 'days', 'years' ),
- ),
- array(
- 42,
- '0 days',
- array( 'days', 'years' ),
- ),
- );
- }
-
- /**
- * @dataProvider provideCheckTitleEncodingData
- */
- function testCheckTitleEncoding( $s ) {
- $this->assertEquals(
- $s,
- $this->lang->checkTitleEncoding($s),
- "checkTitleEncoding('$s')"
- );
- }
-
- function provideCheckTitleEncodingData() {
- return array (
- array( "" ),
- array( "United States of America" ), // 7bit ASCII
- array( rawurldecode( "S%C3%A9rie%20t%C3%A9l%C3%A9vis%C3%A9e" ) ),
- array(
- rawurldecode(
- "Acteur%7CAlbert%20Robbins%7CAnglais%7CAnn%20Donahue%7CAnthony%20E.%20Zuiker%7CCarol%20Mendelsohn"
- )
- ),
- // The following two data sets come from bug 36839. They fail if checkTitleEncoding uses a regexp to test for
- // valid UTF-8 encoding and the pcre.recursion_limit is low (like, say, 1024). They succeed if checkTitleEncoding
- // uses mb_check_encoding for its test.
- array(
- rawurldecode(
- "Acteur%7CAlbert%20Robbins%7CAnglais%7CAnn%20Donahue%7CAnthony%20E.%20Zuiker%7CCarol%20Mendelsohn%7C"
- . "Catherine%20Willows%7CDavid%20Hodges%7CDavid%20Phillips%7CGil%20Grissom%7CGreg%20Sanders%7CHodges%7C"
- . "Internet%20Movie%20Database%7CJim%20Brass%7CLady%20Heather%7C"
- . "Les%20Experts%20(s%C3%A9rie%20t%C3%A9l%C3%A9vis%C3%A9e)%7CLes%20Experts%20:%20Manhattan%7C"
- . "Les%20Experts%20:%20Miami%7CListe%20des%20personnages%20des%20Experts%7C"
- . "Liste%20des%20%C3%A9pisodes%20des%20Experts%7CMod%C3%A8le%20discussion:Palette%20Les%20Experts%7C"
- . "Nick%20Stokes%7CPersonnage%20de%20fiction%7CPersonnage%20fictif%7CPersonnage%20de%20fiction%7C"
- . "Personnages%20r%C3%A9currents%20dans%20Les%20Experts%7CRaymond%20Langston%7CRiley%20Adams%7C"
- . "Saison%201%20des%20Experts%7CSaison%2010%20des%20Experts%7CSaison%2011%20des%20Experts%7C"
- . "Saison%2012%20des%20Experts%7CSaison%202%20des%20Experts%7CSaison%203%20des%20Experts%7C"
- . "Saison%204%20des%20Experts%7CSaison%205%20des%20Experts%7CSaison%206%20des%20Experts%7C"
- . "Saison%207%20des%20Experts%7CSaison%208%20des%20Experts%7CSaison%209%20des%20Experts%7C"
- . "Sara%20Sidle%7CSofia%20Curtis%7CS%C3%A9rie%20t%C3%A9l%C3%A9vis%C3%A9e%7CWallace%20Langham%7C"
- . "Warrick%20Brown%7CWendy%20Simms%7C%C3%89tats-Unis"
- ),
- ),
- array(
- rawurldecode(
- "Mod%C3%A8le%3AArrondissements%20homonymes%7CMod%C3%A8le%3ABandeau%20standard%20pour%20page%20d'homonymie%7C"
- . "Mod%C3%A8le%3ABatailles%20homonymes%7CMod%C3%A8le%3ACantons%20homonymes%7C"
- . "Mod%C3%A8le%3ACommunes%20fran%C3%A7aises%20homonymes%7CMod%C3%A8le%3AFilms%20homonymes%7C"
- . "Mod%C3%A8le%3AGouvernements%20homonymes%7CMod%C3%A8le%3AGuerres%20homonymes%7CMod%C3%A8le%3AHomonymie%7C"
- . "Mod%C3%A8le%3AHomonymie%20bateau%7CMod%C3%A8le%3AHomonymie%20d'%C3%A9tablissements%20scolaires%20ou"
- . "%20universitaires%7CMod%C3%A8le%3AHomonymie%20d'%C3%AEles%7CMod%C3%A8le%3AHomonymie%20de%20clubs%20sportifs%7C"
- . "Mod%C3%A8le%3AHomonymie%20de%20comt%C3%A9s%7CMod%C3%A8le%3AHomonymie%20de%20monument%7C"
- . "Mod%C3%A8le%3AHomonymie%20de%20nom%20romain%7CMod%C3%A8le%3AHomonymie%20de%20parti%20politique%7C"
- . "Mod%C3%A8le%3AHomonymie%20de%20route%7CMod%C3%A8le%3AHomonymie%20dynastique%7C"
- . "Mod%C3%A8le%3AHomonymie%20vid%C3%A9oludique%7CMod%C3%A8le%3AHomonymie%20%C3%A9difice%20religieux%7C"
- . "Mod%C3%A8le%3AInternationalisation%7CMod%C3%A8le%3AIsom%C3%A9rie%7CMod%C3%A8le%3AParonymie%7C"
- . "Mod%C3%A8le%3APatronyme%7CMod%C3%A8le%3APatronyme%20basque%7CMod%C3%A8le%3APatronyme%20italien%7C"
- . "Mod%C3%A8le%3APatronymie%7CMod%C3%A8le%3APersonnes%20homonymes%7CMod%C3%A8le%3ASaints%20homonymes%7C"
- . "Mod%C3%A8le%3ATitres%20homonymes%7CMod%C3%A8le%3AToponymie%7CMod%C3%A8le%3AUnit%C3%A9s%20homonymes%7C"
- . "Mod%C3%A8le%3AVilles%20homonymes%7CMod%C3%A8le%3A%C3%89difices%20religieux%20homonymes"
- )
- )
- );
- }
-
- /**
- * @dataProvider provideRomanNumeralsData
- */
- function testRomanNumerals( $num, $numerals ) {
- $this->assertEquals(
- $numerals,
- Language::romanNumeral( $num ),
- "romanNumeral('$num')"
- );
- }
-
- function provideRomanNumeralsData() {
- return array(
- array( 1, 'I' ),
- array( 2, 'II' ),
- array( 3, 'III' ),
- array( 4, 'IV' ),
- array( 5, 'V' ),
- array( 6, 'VI' ),
- array( 7, 'VII' ),
- array( 8, 'VIII' ),
- array( 9, 'IX' ),
- array( 10, 'X' ),
- array( 20, 'XX' ),
- array( 30, 'XXX' ),
- array( 40, 'XL' ),
- array( 49, 'XLIX' ),
- array( 50, 'L' ),
- array( 60, 'LX' ),
- array( 70, 'LXX' ),
- array( 80, 'LXXX' ),
- array( 90, 'XC' ),
- array( 99, 'XCIX' ),
- array( 100, 'C' ),
- array( 200, 'CC' ),
- array( 300, 'CCC' ),
- array( 400, 'CD' ),
- array( 500, 'D' ),
- array( 600, 'DC' ),
- array( 700, 'DCC' ),
- array( 800, 'DCCC' ),
- array( 900, 'CM' ),
- array( 999, 'CMXCIX' ),
- array( 1000, 'M' ),
- array( 1989, 'MCMLXXXIX' ),
- array( 2000, 'MM' ),
- array( 3000, 'MMM' ),
- array( 4000, 'MMMM' ),
- array( 5000, 'MMMMM' ),
- array( 6000, 'MMMMMM' ),
- array( 7000, 'MMMMMMM' ),
- array( 8000, 'MMMMMMMM' ),
- array( 9000, 'MMMMMMMMM' ),
- array( 9999, 'MMMMMMMMMCMXCIX'),
- array( 10000, 'MMMMMMMMMM' ),
- );
- }
-}
-
diff --git a/tests/phpunit/languages/LanguageTiTest.php b/tests/phpunit/languages/LanguageTiTest.php
deleted file mode 100644
index 4bfaa009..00000000
--- a/tests/phpunit/languages/LanguageTiTest.php
+++ /dev/null
@@ -1,32 +0,0 @@
-lang = Language::factory( 'Ti' );
- }
- function tearDown() {
- unset( $this->lang );
- }
-
- /** @dataProvider providerPlural */
- function testPlural( $result, $value ) {
- $forms = array( 'one', 'many' );
- $this->assertEquals( $result, $this->lang->convertPlural( $value, $forms ) );
- }
-
- function providerPlural() {
- return array (
- array( 'one', 0 ),
- array( 'one', 1 ),
- array( 'many', 2 ),
- );
- }
-}
diff --git a/tests/phpunit/languages/LanguageTlTest.php b/tests/phpunit/languages/LanguageTlTest.php
deleted file mode 100644
index a1facd14..00000000
--- a/tests/phpunit/languages/LanguageTlTest.php
+++ /dev/null
@@ -1,32 +0,0 @@
-lang = Language::factory( 'Tl' );
- }
- function tearDown() {
- unset( $this->lang );
- }
-
- /** @dataProvider providerPlural */
- function testPlural( $result, $value ) {
- $forms = array( 'one', 'many' );
- $this->assertEquals( $result, $this->lang->convertPlural( $value, $forms ) );
- }
-
- function providerPlural() {
- return array (
- array( 'one', 0 ),
- array( 'one', 1 ),
- array( 'many', 2 ),
- );
- }
-}
diff --git a/tests/phpunit/languages/LanguageTrTest.php b/tests/phpunit/languages/LanguageTrTest.php
deleted file mode 100644
index bda4c9d9..00000000
--- a/tests/phpunit/languages/LanguageTrTest.php
+++ /dev/null
@@ -1,68 +0,0 @@
-lang = Language::factory( 'Tr' );
- }
- function tearDown() {
- unset( $this->lang );
- }
-
- /**
- * See @bug 28040
- * Credits to irc://irc.freenode.net/wikipedia-tr users:
- * - berm
- * - []LuCkY[]
- * - Emperyan
- * @see http://en.wikipedia.org/wiki/Dotted_and_dotless_I
- * @dataProvider provideDottedAndDotlessI
- */
- function testDottedAndDotlessI( $func, $input, $inputCase, $expected ) {
- if( $func == 'ucfirst' ) {
- $res = $this->lang->ucfirst( $input );
- } elseif( $func == 'lcfirst' ) {
- $res = $this->lang->lcfirst( $input );
- } else {
- throw new MWException( __METHOD__ . " given an invalid function name '$func'" );
- }
-
- $msg = "Converting $inputCase case '$input' with $func should give '$expected'";
-
- $this->assertEquals( $expected, $res, $msg );
- }
-
- function provideDottedAndDotlessI() {
- return array(
- # function, input, input case, expected
- # Case changed:
- array( 'ucfirst', 'ı', 'lower', 'I' ),
- array( 'ucfirst', 'i', 'lower', 'İ' ),
- array( 'lcfirst', 'I', 'upper', 'ı' ),
- array( 'lcfirst', 'İ', 'upper', 'i' ),
-
- # Already using the correct case
- array( 'ucfirst', 'I', 'upper', 'I' ),
- array( 'ucfirst', 'İ', 'upper', 'İ' ),
- array( 'lcfirst', 'ı', 'lower', 'ı' ),
- array( 'lcfirst', 'i', 'lower', 'i' ),
-
- # A real example taken from bug 28040 using
- # http://tr.wikipedia.org/wiki/%C4%B0Phone
- array( 'lcfirst', 'iPhone', 'lower', 'iPhone' ),
-
- # next case is valid in Turkish but are different words if we
- # consider IPhone is English!
- array( 'lcfirst', 'IPhone', 'upper', 'ıPhone' ),
-
- );
- }
-
-}
diff --git a/tests/phpunit/languages/LanguageUkTest.php b/tests/phpunit/languages/LanguageUkTest.php
deleted file mode 100644
index 60fafb0d..00000000
--- a/tests/phpunit/languages/LanguageUkTest.php
+++ /dev/null
@@ -1,54 +0,0 @@
-lang = Language::factory( 'Uk' );
- }
- function tearDown() {
- unset( $this->lang );
- }
-
- /** @dataProvider providePluralFourForms */
- function testPluralFourForms( $result, $value ) {
- $forms = array( 'one', 'few', 'many', 'other' );
- $this->assertEquals( $result, $this->lang->convertPlural( $value, $forms ) );
- }
-
- function providePluralFourForms() {
- return array (
- array( 'one', 1 ),
- array( 'many', 11 ),
- array( 'one', 91 ),
- array( 'one', 121 ),
- array( 'few', 2 ),
- array( 'few', 3 ),
- array( 'few', 4 ),
- array( 'few', 334 ),
- array( 'many', 5 ),
- array( 'many', 15 ),
- array( 'many', 120 ),
- );
- }
- /** @dataProvider providePluralTwoForms */
- function testPluralTwoForms( $result, $value ) {
- $forms = array( 'one', 'several' );
- $this->assertEquals( $result, $this->lang->convertPlural( $value, $forms ) );
- }
- function providePluralTwoForms() {
- return array (
- array( 'one', 1 ),
- array( 'several', 11 ),
- array( 'several', 91 ),
- array( 'several', 121 ),
- );
- }
-}
diff --git a/tests/phpunit/languages/LanguageUzTest.php b/tests/phpunit/languages/LanguageUzTest.php
deleted file mode 100644
index 72387283..00000000
--- a/tests/phpunit/languages/LanguageUzTest.php
+++ /dev/null
@@ -1,120 +0,0 @@
-
- * @copyright Copyright © 2012, Robin Pepermans
- * @copyright Copyright © 2011, Antoine Musso
- * @file
- */
-
-require_once dirname( __DIR__ ) . '/bootstrap.php';
-
-/** Tests for MediaWiki languages/LanguageUz.php */
-class LanguageUzTest extends MediaWikiTestCase {
- /* Language object. Initialized before each test */
- private $lang;
-
- function setUp() {
- $this->lang = Language::factory( 'uz' );
- }
- function tearDown() {
- unset( $this->lang );
- }
-
- /**
- * @author Nikola Smolenski
- */
- function testConversionToCyrillic() {
- // A convertion of Latin to Cyrillic
- $this->assertEquals( 'абвгғ',
- $this->convertToCyrillic( 'abvggʻ' )
- );
- // Same as above, but assert that -{}-s must be removed and not converted
- $this->assertEquals( 'ljабnjвгўоdb',
- $this->convertToCyrillic( '-{lj}-ab-{nj}-vgoʻo-{db}-' )
- );
- // A simple convertion of Cyrillic to Cyrillic
- $this->assertEquals( 'абвг',
- $this->convertToCyrillic( 'абвг' )
- );
- // Same as above, but assert that -{}-s must be removed and not converted
- $this->assertEquals( 'ljабnjвгdaž',
- $this->convertToCyrillic( '-{lj}-аб-{nj}-вг-{da}-ž' )
- );
- }
-
- function testConversionToLatin() {
- // A simple convertion of Latin to Latin
- $this->assertEquals( 'abdef',
- $this->convertToLatin( 'abdef' )
- );
- // A convertion of Cyrillic to Latin
- $this->assertEquals( 'gʻabtsdOʻQyo',
- $this->convertToLatin( 'ғабцдЎҚё' )
- );
- }
-
- ##### HELPERS #####################################################
- /**
- * Wrapper to verify text stay the same after applying conversion
- * @param $text string Text to convert
- * @param $variant string Language variant 'uz-cyrl' or 'uz-latn'
- * @param $msg string Optional message
- */
- function assertUnConverted( $text, $variant, $msg = '' ) {
- $this->assertEquals(
- $text,
- $this->convertTo( $text, $variant ),
- $msg
- );
- }
- /**
- * Wrapper to verify a text is different once converted to a variant.
- * @param $text string Text to convert
- * @param $variant string Language variant 'uz-cyrl' or 'uz-latn'
- * @param $msg string Optional message
- */
- function assertConverted( $text, $variant, $msg = '' ) {
- $this->assertNotEquals(
- $text,
- $this->convertTo( $text, $variant ),
- $msg
- );
- }
-
- /**
- * Verifiy the given Cyrillic text is not converted when using
- * using the cyrillic variant and converted to Latin when using
- * the Latin variant.
- */
- function assertCyrillic( $text, $msg = '' ) {
- $this->assertUnConverted( $text, 'uz-cyrl', $msg );
- $this->assertConverted( $text, 'uz-latn', $msg );
- }
- /**
- * Verifiy the given Latin text is not converted when using
- * using the Latin variant and converted to Cyrillic when using
- * the Cyrillic variant.
- */
- function assertLatin( $text, $msg = '' ) {
- $this->assertUnConverted( $text, 'uz-latn', $msg );
- $this->assertConverted( $text, 'uz-cyrl', $msg );
- }
-
-
- /** Wrapper for converter::convertTo() method*/
- function convertTo( $text, $variant ) {
- return $this->lang->mConverter->convertTo( $text, $variant );
- }
- function convertToCyrillic( $text ) {
- return $this->convertTo( $text, 'uz-cyrl' );
- }
- function convertToLatin( $text ) {
- return $this->convertTo( $text, 'uz-latn' );
- }
-}
diff --git a/tests/phpunit/languages/LanguageWaTest.php b/tests/phpunit/languages/LanguageWaTest.php
deleted file mode 100644
index 172f19b9..00000000
--- a/tests/phpunit/languages/LanguageWaTest.php
+++ /dev/null
@@ -1,32 +0,0 @@
-lang = Language::factory( 'Wa' );
- }
- function tearDown() {
- unset( $this->lang );
- }
-
- /** @dataProvider providerPlural */
- function testPlural( $result, $value ) {
- $forms = array( 'one', 'many' );
- $this->assertEquals( $result, $this->lang->convertPlural( $value, $forms ) );
- }
-
- function providerPlural() {
- return array (
- array( 'one', 0 ),
- array( 'one', 1 ),
- array( 'many', 2 ),
- );
- }
-}
diff --git a/tests/phpunit/languages/utils/CLDRPluralRuleEvaluatorTest.php b/tests/phpunit/languages/utils/CLDRPluralRuleEvaluatorTest.php
deleted file mode 100644
index 033164b0..00000000
--- a/tests/phpunit/languages/utils/CLDRPluralRuleEvaluatorTest.php
+++ /dev/null
@@ -1,95 +0,0 @@
-assertEquals( $expected, $result, $comment );
- }
-
- /**
- * @dataProvider invalidTestCases
- * @expectedException CLDRPluralRuleError
- */
- function testInvalidRules( $rules, $comment ) {
- CLDRPluralRuleEvaluator::evaluate( 1, (array) $rules );
- }
-
- function validTestCases() {
- $tests = array(
- # expected, number, rule, comment
- array( 0, 'n is 1', 1, 'integer number and is' ),
- array( 0, 'n is 1', "1", 'string integer number and is' ),
- array( 0, 'n is 1', 1.0, 'float number and is' ),
- array( 0, 'n is 1', "1.0", 'string float number and is' ),
- array( 1, 'n is 1', 1.1, 'float number and is' ),
- array( 1, 'n is 1', 2, 'float number and is' ),
-
- array( 0, 'n in 1,3,5', 3, '' ),
- array( 1, 'n not in 1,3,5', 5, '' ),
-
- array( 1, 'n in 1,3,5', 2, '' ),
- array( 0, 'n not in 1,3,5', 4, '' ),
-
- array( 0, 'n in 1..3', 2, '' ),
- array( 0, 'n in 1..3', 3, 'in is inclusive' ),
- array( 1, 'n in 1..3', 0, '' ),
-
- array( 1, 'n not in 1..3', 2, '' ),
- array( 1, 'n not in 1..3', 3, 'in is inclusive' ),
- array( 0, 'n not in 1..3', 0, '' ),
-
- array( 1, 'n is not 1 and n is not 2 and n is not 3', 1, 'and relation' ),
- array( 0, 'n is not 1 and n is not 2 and n is not 4', 3, 'and relation' ),
-
- array( 0, 'n is not 1 or n is 1', 1, 'or relation' ),
- array( 1, 'n is 1 or n is 2', 3, 'or relation' ),
-
- array( 0, 'n is 1', 1, 'extra whitespace' ),
-
- array( 0, 'n mod 3 is 1', 7, 'mod' ),
- array( 0, 'n mod 3 is not 1', 4.3, 'mod with floats' ),
-
- array( 0, 'n within 1..3', 2, 'within with integer' ),
- array( 0, 'n within 1..3', 2.5, 'within with float' ),
- array( 0, 'n in 1..3', 2, 'in with integer' ),
- array( 1, 'n in 1..3', 2.5, 'in with float' ),
-
- array( 0, 'n in 3 or n is 4 and n is 5', 3, 'and binds more tightly than or' ),
- array( 1, 'n is 3 or n is 4 and n is 5', 4, 'and binds more tightly than or' ),
-
- array( 0, 'n mod 10 in 3..4,9 and n mod 100 not in 10..19,70..79,90..99', 24, 'breton rule' ),
- array( 1, 'n mod 10 in 3..4,9 and n mod 100 not in 10..19,70..79,90..99', 25, 'breton rule' ),
-
- array( 0, 'n within 0..2 and n is not 2', 0, 'french rule' ),
- array( 0, 'n within 0..2 and n is not 2', 1, 'french rule' ),
- array( 0, 'n within 0..2 and n is not 2', 1.2, 'french rule' ),
- array( 1, 'n within 0..2 and n is not 2', 2, 'french rule' ),
-
- array( 1, 'n in 3..10,13..19', 2, 'scottish rule - ranges with comma' ),
- array( 0, 'n in 3..10,13..19', 4, 'scottish rule - ranges with comma' ),
- array( 1, 'n in 3..10,13..19', 12.999, 'scottish rule - ranges with comma' ),
- array( 0, 'n in 3..10,13..19', 13, 'scottish rule - ranges with comma' ),
-
- array( 0, '5 mod 3 is n', 2, 'n as result of mod - no need to pass' ),
- );
-
- return $tests;
- }
-
- function invalidTestCases() {
- $tests = array(
- array( 'n mod mod 5 is 1', 'mod mod' ),
- array( 'n', 'just n' ),
- array( 'n is in 5', 'is in' ),
- );
- return $tests;
- }
-
-}
diff --git a/tests/phpunit/maintenance/DumpTestCase.php b/tests/phpunit/maintenance/DumpTestCase.php
deleted file mode 100644
index d1344389..00000000
--- a/tests/phpunit/maintenance/DumpTestCase.php
+++ /dev/null
@@ -1,352 +0,0 @@
-doEdit( $text, $summary );
- if ( $status->isGood() ) {
- $value = $status->getValue();
- $revision = $value['revision'];
- $revision_id = $revision->getId();
- $text_id = $revision->getTextId();
- if ( ( $revision_id > 0 ) && ( $text_id > 0 ) ) {
- return array( $revision_id, $text_id );
- }
- }
- throw new MWException( "Could not determine revision id (" . $status->getWikiText() . ")" );
- }
-
-
- /**
- * gunzips the given file and stores the result in the original file name
- *
- * @param $fname string: filename to read the gzipped data from and stored
- * the gunzipped data into
- */
- protected function gunzip( $fname ) {
- $gzipped_contents = file_get_contents( $fname );
- if ( $gzipped_contents === FALSE ) {
- $this->fail( "Could not get contents of $fname" );
- }
- // We resort to use gzinflate instead of gzdecode, as gzdecode
- // need not be available
- $contents = gzinflate( substr( $gzipped_contents, 10, -8 ) );
- $this->assertEquals( strlen( $contents ),
- file_put_contents( $fname, $contents ), "# bytes written" );
- }
-
- /**
- * Default set up function.
- *
- * Clears $wgUser, and reports errors from addDBData to PHPUnit
- */
- public function setUp() {
- global $wgUser;
-
- parent::setUp();
-
- // Check if any Exception is stored for rethrowing from addDBData
- // @see self::exceptionFromAddDBData
- if ( $this->exceptionFromAddDBData !== null ) {
- throw $this->exceptionFromAddDBData;
- }
-
- $wgUser = new User();
- }
-
- /**
- * Checks for test output consisting only of lines containing ETA announcements
- */
- function expectETAOutput() {
- // Newer PHPUnits require assertion about the output using PHPUnit's own
- // expectOutput[...] functions. However, the PHPUnit shipped prediactes
- // do not allow to check /each/ line of the output using /readable/ REs.
- // So we ...
- //
- // 1. ... add a dummy output checking to make PHPUnit not complain
- // about unchecked test output
- $this->expectOutputRegex( '//' );
-
- // 2. Do the real output checking on our own.
- $lines = explode( "\n", $this->getActualOutput() );
- $this->assertGreaterThan( 1, count( $lines ), "Minimal lines of produced output" );
- $this->assertEquals( '', array_pop( $lines ), "Output ends in LF" );
- $timestamp_re = "[0-9]{4}-[01][0-9]-[0-3][0-9] [0-2][0-9]:[0-5][0-9]:[0-6][0-9]";
- foreach ( $lines as $line ) {
- $this->assertRegExp( "/$timestamp_re: .* \(ID [0-9]+\) [0-9]* pages .*, [0-9]* revs .*, ETA/", $line );
- }
- }
-
-
- /**
- * Step the current XML reader until node end of given name is found.
- *
- * @param $name string: name of the closing element to look for
- * (e.g.: "mediawiki" when looking for )
- *
- * @return bool: true iff the end node could be found. false otherwise.
- */
- protected function skipToNodeEnd( $name ) {
- while ( $this->xml->read() ) {
- if ( $this->xml->nodeType == XMLReader::END_ELEMENT &&
- $this->xml->name == $name ) {
- return true;
- }
- }
- return false;
- }
-
- /**
- * Step the current XML reader to the first element start after the node
- * end of a given name.
- *
- * @param $name string: name of the closing element to look for
- * (e.g.: "mediawiki" when looking for )
- *
- * @return bool: true iff new element after the closing of $name could be
- * found. false otherwise.
- */
- protected function skipPastNodeEnd( $name ) {
- $this->assertTrue( $this->skipToNodeEnd( $name ),
- "Skipping to end of $name" );
- while ( $this->xml->read() ) {
- if ( $this->xml->nodeType == XMLReader::ELEMENT ) {
- return true;
- }
- }
- return false;
- }
-
- /**
- * Opens an XML file to analyze and optionally skips past siteinfo.
- *
- * @param $fname string: name of file to analyze
- * @param $skip_siteinfo bool: (optional) If true, step the xml reader
- * to the first element after
- */
- protected function assertDumpStart( $fname, $skip_siteinfo = true ) {
- $this->xml = new XMLReader();
- $this->assertTrue( $this->xml->open( $fname ),
- "Opening temporary file $fname via XMLReader failed" );
- if ( $skip_siteinfo ) {
- $this->assertTrue( $this->skipPastNodeEnd( "siteinfo" ),
- "Skipping past end of siteinfo" );
- }
- }
-
- /**
- * Asserts that the xml reader is at the final closing tag of an xml file and
- * closes the reader.
- *
- * @param $tag string: (optional) the name of the final tag
- * (e.g.: "mediawiki" for )
- */
- protected function assertDumpEnd( $name = "mediawiki" ) {
- $this->assertNodeEnd( $name, false );
- if ( $this->xml->read() ) {
- $this->skipWhitespace();
- }
- $this->assertEquals( $this->xml->nodeType, XMLReader::NONE,
- "No proper entity left to parse" );
- $this->xml->close();
- }
-
- /**
- * Steps the xml reader over white space
- */
- protected function skipWhitespace() {
- $cont = true;
- while ( $cont && ( ( $this->xml->nodeType == XMLReader::WHITESPACE )
- || ( $this->xml->nodeType == XMLReader::SIGNIFICANT_WHITESPACE ) ) ) {
- $cont = $this->xml->read();
- }
- }
-
- /**
- * Asserts that the xml reader is at an element of given name, and optionally
- * skips past it.
- *
- * @param $name string: the name of the element to check for
- * (e.g.: "mediawiki" for )
- * @param $skip bool: (optional) if true, skip past the found element
- */
- protected function assertNodeStart( $name, $skip = true ) {
- $this->assertEquals( $name, $this->xml->name, "Node name" );
- $this->assertEquals( XMLReader::ELEMENT, $this->xml->nodeType, "Node type" );
- if ( $skip ) {
- $this->assertTrue( $this->xml->read(), "Skipping past start tag" );
- }
- }
-
- /**
- * Asserts that the xml reader is at an closing element of given name, and optionally
- * skips past it.
- *
- * @param $name string: the name of the closing element to check for
- * (e.g.: "mediawiki" for )
- * @param $skip bool: (optional) if true, skip past the found element
- */
- protected function assertNodeEnd( $name, $skip = true ) {
- $this->assertEquals( $name, $this->xml->name, "Node name" );
- $this->assertEquals( XMLReader::END_ELEMENT, $this->xml->nodeType, "Node type" );
- if ( $skip ) {
- $this->assertTrue( $this->xml->read(), "Skipping past end tag" );
- }
- }
-
-
- /**
- * Asserts that the xml reader is at an element of given tag that contains a given text,
- * and skips over the element.
- *
- * @param $name string: the name of the element to check for
- * (e.g.: "mediawiki" for ...)
- * @param $text string|false: If string, check if it equals the elements text.
- * If false, ignore the element's text
- * @param $skip_ws bool: (optional) if true, skip past white spaces that trail the
- * closing element.
- */
- protected function assertTextNode( $name, $text, $skip_ws = true ) {
- $this->assertNodeStart( $name );
-
- if ( $text !== false ) {
- $this->assertEquals( $text, $this->xml->value, "Text of node " . $name );
- }
- $this->assertTrue( $this->xml->read(), "Skipping past processed text of " . $name );
- $this->assertNodeEnd( $name );
-
- if ( $skip_ws ) {
- $this->skipWhitespace();
- }
- }
-
- /**
- * Asserts that the xml reader is at the start of a page element and skips over the first
- * tags, after checking them.
- *
- * Besides the opening page element, this function also checks for and skips over the
- * title, ns, and id tags. Hence after this function, the xml reader is at the first
- * revision of the current page.
- *
- * @param $id int: id of the page to assert
- * @param $ns int: number of namespage to assert
- * @param $name string: title of the current page
- */
- protected function assertPageStart( $id, $ns, $name ) {
-
- $this->assertNodeStart( "page" );
- $this->skipWhitespace();
-
- $this->assertTextNode( "title", $name );
- $this->assertTextNode( "ns", $ns );
- $this->assertTextNode( "id", $id );
-
- }
-
- /**
- * Asserts that the xml reader is at the page's closing element and skips to the next
- * element.
- */
- protected function assertPageEnd() {
- $this->assertNodeEnd( "page" );
- $this->skipWhitespace();
- }
-
- /**
- * Asserts that the xml reader is at a revision and checks its representation before
- * skipping over it.
- *
- * @param $id int: id of the revision
- * @param $summary string: summary of the revision
- * @param $text_id int: id of the revision's text
- * @param $text_bytes int: # of bytes in the revision's text
- * @param $text_sha1 string: the base36 SHA-1 of the revision's text
- * @param $text string|false: (optional) The revision's string, or false to check for a
- * revision stub
- * @param $parentid int|false: (optional) id of the parent revision
- */
- protected function assertRevision( $id, $summary, $text_id, $text_bytes, $text_sha1, $text = false, $parentid = false ) {
-
- $this->assertNodeStart( "revision" );
- $this->skipWhitespace();
-
- $this->assertTextNode( "id", $id );
- if ( $parentid !== false ) {
- $this->assertTextNode( "parentid", $parentid );
- }
- $this->assertTextNode( "timestamp", false );
-
- $this->assertNodeStart( "contributor" );
- $this->skipWhitespace();
- $this->assertTextNode( "ip", false );
- $this->assertNodeEnd( "contributor" );
- $this->skipWhitespace();
-
- $this->assertTextNode( "comment", $summary );
-
- $this->assertTextNode( "sha1", $text_sha1 );
-
- $this->assertNodeStart( "text", false );
- if ( $text_bytes !== false ) {
- $this->assertEquals( $this->xml->getAttribute( "bytes" ), $text_bytes,
- "Attribute 'bytes' of revision " . $id );
- }
-
- if ( $text === false ) {
- // Testing for a stub
- $this->assertEquals( $this->xml->getAttribute( "id" ), $text_id,
- "Text id of revision " . $id );
- $this->assertFalse( $this->xml->hasValue, "Revision has text" );
- $this->assertTrue( $this->xml->read(), "Skipping text start tag" );
- if ( ( $this->xml->nodeType == XMLReader::END_ELEMENT )
- && ( $this->xml->name == "text" ) ) {
-
- $this->xml->read();
- }
- $this->skipWhitespace();
- } else {
- // Testing for a real dump
- $this->assertTrue( $this->xml->read(), "Skipping text start tag" );
- $this->assertEquals( $text, $this->xml->value, "Text of revision " . $id );
- $this->assertTrue( $this->xml->read(), "Skipping past text" );
- $this->assertNodeEnd( "text" );
- $this->skipWhitespace();
- }
-
- $this->assertNodeEnd( "revision" );
- $this->skipWhitespace();
- }
-
-}
diff --git a/tests/phpunit/maintenance/MaintenanceTest.php b/tests/phpunit/maintenance/MaintenanceTest.php
deleted file mode 100644
index 4a6f08fa..00000000
--- a/tests/phpunit/maintenance/MaintenanceTest.php
+++ /dev/null
@@ -1,812 +0,0 @@
-shutdownSimulated ) {
- $this->testCase->fail( __METHOD__ . " called more than once" );
- }
-
- // The cleanup action.
- $this->outputChanneled( false );
-
- // Bookkeeping that we simulated the clean up.
- $this->shutdownSimulated = true;
- }
-
- // Note that the "public" here does not change visibility
- public function outputChanneled( $msg, $channel = null ) {
- if ( $this->shutdownSimulated ) {
- if ( $msg !== false ) {
- $this->testCase->fail( "Already past simulated shutdown, but msg is "
- . "not false. Did the hack in Maintenance.php change? Please "
- . "adapt the test case or Maintenance.php" );
- }
-
- // The current call is the one registered via register_shutdown_function.
- // We can safely ignore it, as we simulated this one via simulateShutdown
- // before (if we did not, the destructor of this instance will warn about
- // it)
- return;
- }
-
- return call_user_func_array ( array( "parent", __FUNCTION__ ), func_get_args() );
- }
-
- /**
- * Safety net around register_shutdown_function of Maintenance.php
- */
- public function __destruct() {
- if ( ( ! $this->shutdownSimulated ) && ( ! $this->testCase->hasFailed() ) ) {
- // Someone generated a MaintenanceFixup instance without calling
- // simulateShutdown. We'd have to raise a PHPUnit exception to correctly
- // flag this illegal usage. However, we are already in a destruktor, which
- // would trigger undefined behaviour. Hence, we can only report to the
- // error output :( Hopefully people read the PHPUnit output.
- fwrite( STDERR, "ERROR! Instance of " . __CLASS__ . " destructed without "
- . "calling simulateShutdown method. Call simulateShutdown on the "
- . "instance before it gets destructed." );
- }
-
- // The following guard is required, as PHP does not offer default destructors :(
- if ( is_callable( "parent::__destruct" ) ) {
- parent::__destruct();
- }
- }
-
- public function __construct( MediaWikiTestCase $testCase ) {
- parent::__construct();
- $this->testCase = $testCase;
- }
-
-
-
- // --- Making protected functions visible for test
-
- public function output( $out, $channel = null ) {
- // Just to make PHP not nag about signature mismatches, we copied
- // Maintenance::output signature. However, we do not use (or rely on)
- // those variables. Instead we pass to Maintenance::output whatever we
- // receive at runtime.
- return call_user_func_array ( array( "parent", __FUNCTION__ ), func_get_args() );
- }
-
-
-
- // --- Requirements for getting instance of abstract class
-
- public function execute() {
- $this->testCase->fail( __METHOD__ . " called unexpectedly" );
- }
-
-}
-
-class MaintenanceTest extends MediaWikiTestCase {
-
-
- /**
- * The main Maintenance instance that is used for testing.
- *
- * @var MaintenanceFixup
- */
- private $m;
-
-
- protected function setUp() {
- parent::setUp();
- $this->m = new MaintenanceFixup( $this );
- }
-
-
- /**
- * asserts the output before and after simulating shutdown
- *
- * This function simulates shutdown of self::m.
- *
- * @param $preShutdownOutput string: expected output before simulating shutdown
- * @param $expectNLAppending bool: Whether or not shutdown simulation is expected
- * to add a newline to the output. If false, $preShutdownOutput is the
- * expected output after shutdown simulation. Otherwise,
- * $preShutdownOutput with an appended newline is the expected output
- * after shutdown simulation.
- */
- private function assertOutputPrePostShutdown( $preShutdownOutput, $expectNLAppending ) {
-
- $this->assertEquals( $preShutdownOutput, $this->getActualOutput(),
- "Output before shutdown simulation" );
-
- $this->m->simulateShutdown();
-
- $postShutdownOutput = $preShutdownOutput . ( $expectNLAppending ? "\n" : "" );
- $this->expectOutputString( $postShutdownOutput );
- }
-
-
- // Although the following tests do not seem to be too consistent (compare for
- // example the newlines within the test.*StringString tests, or the
- // test.*Intermittent.* tests), the objective of these tests is not to describe
- // consistent behaviour, but rather currently existing behaviour.
-
-
- function testOutputEmpty() {
- $this->m->output( "" );
- $this->assertOutputPrePostShutdown( "", False );
- }
-
- function testOutputString() {
- $this->m->output( "foo" );
- $this->assertOutputPrePostShutdown( "foo", False );
- }
-
- function testOutputStringString() {
- $this->m->output( "foo" );
- $this->m->output( "bar" );
- $this->assertOutputPrePostShutdown( "foobar", False );
- }
-
- function testOutputStringNL() {
- $this->m->output( "foo\n" );
- $this->assertOutputPrePostShutdown( "foo\n", False );
- }
-
- function testOutputStringNLNL() {
- $this->m->output( "foo\n\n" );
- $this->assertOutputPrePostShutdown( "foo\n\n", False );
- }
-
- function testOutputStringNLString() {
- $this->m->output( "foo\nbar" );
- $this->assertOutputPrePostShutdown( "foo\nbar", False );
- }
-
- function testOutputStringNLStringNL() {
- $this->m->output( "foo\nbar\n" );
- $this->assertOutputPrePostShutdown( "foo\nbar\n", False );
- }
-
- function testOutputStringNLStringNLLinewise() {
- $this->m->output( "foo\n" );
- $this->m->output( "bar\n" );
- $this->assertOutputPrePostShutdown( "foo\nbar\n", False );
- }
-
- function testOutputStringNLStringNLArbitrary() {
- $this->m->output( "" );
- $this->m->output( "foo" );
- $this->m->output( "" );
- $this->m->output( "\n" );
- $this->m->output( "ba" );
- $this->m->output( "" );
- $this->m->output( "r\n" );
- $this->assertOutputPrePostShutdown( "foo\nbar\n", False );
- }
-
- function testOutputStringNLStringNLArbitraryAgain() {
- $this->m->output( "" );
- $this->m->output( "foo" );
- $this->m->output( "" );
- $this->m->output( "\nb" );
- $this->m->output( "a" );
- $this->m->output( "" );
- $this->m->output( "r\n" );
- $this->assertOutputPrePostShutdown( "foo\nbar\n", False );
- }
-
- function testOutputWNullChannelEmpty() {
- $this->m->output( "", null );
- $this->assertOutputPrePostShutdown( "", False );
- }
-
- function testOutputWNullChannelString() {
- $this->m->output( "foo", null );
- $this->assertOutputPrePostShutdown( "foo", False );
- }
-
- function testOutputWNullChannelStringString() {
- $this->m->output( "foo", null );
- $this->m->output( "bar", null );
- $this->assertOutputPrePostShutdown( "foobar", False );
- }
-
- function testOutputWNullChannelStringNL() {
- $this->m->output( "foo\n", null );
- $this->assertOutputPrePostShutdown( "foo\n", False );
- }
-
- function testOutputWNullChannelStringNLNL() {
- $this->m->output( "foo\n\n", null );
- $this->assertOutputPrePostShutdown( "foo\n\n", False );
- }
-
- function testOutputWNullChannelStringNLString() {
- $this->m->output( "foo\nbar", null );
- $this->assertOutputPrePostShutdown( "foo\nbar", False );
- }
-
- function testOutputWNullChannelStringNLStringNL() {
- $this->m->output( "foo\nbar\n", null );
- $this->assertOutputPrePostShutdown( "foo\nbar\n", False );
- }
-
- function testOutputWNullChannelStringNLStringNLLinewise() {
- $this->m->output( "foo\n", null );
- $this->m->output( "bar\n", null );
- $this->assertOutputPrePostShutdown( "foo\nbar\n", False );
- }
-
- function testOutputWNullChannelStringNLStringNLArbitrary() {
- $this->m->output( "", null );
- $this->m->output( "foo", null );
- $this->m->output( "", null );
- $this->m->output( "\n", null );
- $this->m->output( "ba", null );
- $this->m->output( "", null );
- $this->m->output( "r\n", null );
- $this->assertOutputPrePostShutdown( "foo\nbar\n", False );
- }
-
- function testOutputWNullChannelStringNLStringNLArbitraryAgain() {
- $this->m->output( "", null );
- $this->m->output( "foo", null );
- $this->m->output( "", null );
- $this->m->output( "\nb", null );
- $this->m->output( "a", null );
- $this->m->output( "", null );
- $this->m->output( "r\n", null );
- $this->assertOutputPrePostShutdown( "foo\nbar\n", False );
- }
-
- function testOutputWChannelString() {
- $this->m->output( "foo", "bazChannel" );
- $this->assertOutputPrePostShutdown( "foo", True );
- }
-
- function testOutputWChannelStringNL() {
- $this->m->output( "foo\n", "bazChannel" );
- $this->assertOutputPrePostShutdown( "foo", True );
- }
-
- function testOutputWChannelStringNLNL() {
- // If this test fails, note that output takes strings with double line
- // endings (although output's implementation in this situation calls
- // outputChanneled with a string ending in a nl ... which is not allowed
- // according to the documentation of outputChanneled)
- $this->m->output( "foo\n\n", "bazChannel" );
- $this->assertOutputPrePostShutdown( "foo\n", True );
- }
-
- function testOutputWChannelStringNLString() {
- $this->m->output( "foo\nbar", "bazChannel" );
- $this->assertOutputPrePostShutdown( "foo\nbar", True );
- }
-
- function testOutputWChannelStringNLStringNL() {
- $this->m->output( "foo\nbar\n", "bazChannel" );
- $this->assertOutputPrePostShutdown( "foo\nbar", True );
- }
-
- function testOutputWChannelStringNLStringNLLinewise() {
- $this->m->output( "foo\n", "bazChannel" );
- $this->m->output( "bar\n", "bazChannel" );
- $this->assertOutputPrePostShutdown( "foobar", True );
- }
-
- function testOutputWChannelStringNLStringNLArbitrary() {
- $this->m->output( "", "bazChannel" );
- $this->m->output( "foo", "bazChannel" );
- $this->m->output( "", "bazChannel" );
- $this->m->output( "\n", "bazChannel" );
- $this->m->output( "ba", "bazChannel" );
- $this->m->output( "", "bazChannel" );
- $this->m->output( "r\n", "bazChannel" );
- $this->assertOutputPrePostShutdown( "foobar", True );
- }
-
- function testOutputWChannelStringNLStringNLArbitraryAgain() {
- $this->m->output( "", "bazChannel" );
- $this->m->output( "foo", "bazChannel" );
- $this->m->output( "", "bazChannel" );
- $this->m->output( "\nb", "bazChannel" );
- $this->m->output( "a", "bazChannel" );
- $this->m->output( "", "bazChannel" );
- $this->m->output( "r\n", "bazChannel" );
- $this->assertOutputPrePostShutdown( "foo\nbar", True );
- }
-
- function testOutputWMultipleChannelsChannelChange() {
- $this->m->output( "foo", "bazChannel" );
- $this->m->output( "bar", "bazChannel" );
- $this->m->output( "qux", "quuxChannel" );
- $this->m->output( "corge", "bazChannel" );
- $this->assertOutputPrePostShutdown( "foobar\nqux\ncorge", True );
- }
-
- function testOutputWMultipleChannelsChannelChangeNL() {
- $this->m->output( "foo", "bazChannel" );
- $this->m->output( "bar\n", "bazChannel" );
- $this->m->output( "qux\n", "quuxChannel" );
- $this->m->output( "corge", "bazChannel" );
- $this->assertOutputPrePostShutdown( "foobar\nqux\ncorge", True );
- }
-
- function testOutputWAndWOChannelStringStartWO() {
- $this->m->output( "foo" );
- $this->m->output( "bar", "bazChannel" );
- $this->m->output( "qux" );
- $this->m->output( "quux", "bazChannel" );
- $this->assertOutputPrePostShutdown( "foobar\nquxquux", True );
- }
-
- function testOutputWAndWOChannelStringStartW() {
- $this->m->output( "foo", "bazChannel" );
- $this->m->output( "bar" );
- $this->m->output( "qux", "bazChannel" );
- $this->m->output( "quux" );
- $this->assertOutputPrePostShutdown( "foo\nbarqux\nquux", False );
- }
-
- function testOutputWChannelTypeSwitch() {
- $this->m->output( "foo", 1 );
- $this->m->output( "bar", 1.0 );
- $this->assertOutputPrePostShutdown( "foo\nbar", True );
- }
-
- function testOutputIntermittentEmpty() {
- $this->m->output( "foo" );
- $this->m->output( "" );
- $this->m->output( "bar" );
- $this->assertOutputPrePostShutdown( "foobar", False );
- }
-
- function testOutputIntermittentFalse() {
- $this->m->output( "foo" );
- $this->m->output( false );
- $this->m->output( "bar" );
- $this->assertOutputPrePostShutdown( "foobar", False );
- }
-
- function testOutputIntermittentFalseAfterOtherChannel() {
- $this->m->output( "qux", "quuxChannel" );
- $this->m->output( "foo" );
- $this->m->output( false );
- $this->m->output( "bar" );
- $this->assertOutputPrePostShutdown( "qux\nfoobar", False );
- }
-
- function testOutputWNullChannelIntermittentEmpty() {
- $this->m->output( "foo", null );
- $this->m->output( "", null );
- $this->m->output( "bar", null );
- $this->assertOutputPrePostShutdown( "foobar", False );
- }
-
- function testOutputWNullChannelIntermittentFalse() {
- $this->m->output( "foo", null );
- $this->m->output( false, null );
- $this->m->output( "bar", null );
- $this->assertOutputPrePostShutdown( "foobar", False );
- }
-
- function testOutputWChannelIntermittentEmpty() {
- $this->m->output( "foo", "bazChannel" );
- $this->m->output( "", "bazChannel" );
- $this->m->output( "bar", "bazChannel" );
- $this->assertOutputPrePostShutdown( "foobar", True );
- }
-
- function testOutputWChannelIntermittentFalse() {
- $this->m->output( "foo", "bazChannel" );
- $this->m->output( false, "bazChannel" );
- $this->m->output( "bar", "bazChannel" );
- $this->assertOutputPrePostShutdown( "foobar", True );
- }
-
- // Note that (per documentation) outputChanneled does take strings that end
- // in \n, hence we do not test such strings.
-
- function testOutputChanneledEmpty() {
- $this->m->outputChanneled( "" );
- $this->assertOutputPrePostShutdown( "\n", False );
- }
-
- function testOutputChanneledString() {
- $this->m->outputChanneled( "foo" );
- $this->assertOutputPrePostShutdown( "foo\n", False );
- }
-
- function testOutputChanneledStringString() {
- $this->m->outputChanneled( "foo" );
- $this->m->outputChanneled( "bar" );
- $this->assertOutputPrePostShutdown( "foo\nbar\n", False );
- }
-
- function testOutputChanneledStringNLString() {
- $this->m->outputChanneled( "foo\nbar" );
- $this->assertOutputPrePostShutdown( "foo\nbar\n", False );
- }
-
- function testOutputChanneledStringNLStringNLArbitraryAgain() {
- $this->m->outputChanneled( "" );
- $this->m->outputChanneled( "foo" );
- $this->m->outputChanneled( "" );
- $this->m->outputChanneled( "\nb" );
- $this->m->outputChanneled( "a" );
- $this->m->outputChanneled( "" );
- $this->m->outputChanneled( "r" );
- $this->assertOutputPrePostShutdown( "\nfoo\n\n\nb\na\n\nr\n", False );
- }
-
- function testOutputChanneledWNullChannelEmpty() {
- $this->m->outputChanneled( "", null );
- $this->assertOutputPrePostShutdown( "\n", False );
- }
-
- function testOutputChanneledWNullChannelString() {
- $this->m->outputChanneled( "foo", null );
- $this->assertOutputPrePostShutdown( "foo\n", False );
- }
-
- function testOutputChanneledWNullChannelStringString() {
- $this->m->outputChanneled( "foo", null );
- $this->m->outputChanneled( "bar", null );
- $this->assertOutputPrePostShutdown( "foo\nbar\n", False );
- }
-
- function testOutputChanneledWNullChannelStringNLString() {
- $this->m->outputChanneled( "foo\nbar", null );
- $this->assertOutputPrePostShutdown( "foo\nbar\n", False );
- }
-
- function testOutputChanneledWNullChannelStringNLStringNLArbitraryAgain() {
- $this->m->outputChanneled( "", null );
- $this->m->outputChanneled( "foo", null );
- $this->m->outputChanneled( "", null );
- $this->m->outputChanneled( "\nb", null );
- $this->m->outputChanneled( "a", null );
- $this->m->outputChanneled( "", null );
- $this->m->outputChanneled( "r", null );
- $this->assertOutputPrePostShutdown( "\nfoo\n\n\nb\na\n\nr\n", False );
- }
-
- function testOutputChanneledWChannelString() {
- $this->m->outputChanneled( "foo", "bazChannel" );
- $this->assertOutputPrePostShutdown( "foo", True );
- }
-
- function testOutputChanneledWChannelStringNLString() {
- $this->m->outputChanneled( "foo\nbar", "bazChannel" );
- $this->assertOutputPrePostShutdown( "foo\nbar", True );
- }
-
- function testOutputChanneledWChannelStringString() {
- $this->m->outputChanneled( "foo", "bazChannel" );
- $this->m->outputChanneled( "bar", "bazChannel" );
- $this->assertOutputPrePostShutdown( "foobar", True );
- }
-
- function testOutputChanneledWChannelStringNLStringNLArbitraryAgain() {
- $this->m->outputChanneled( "", "bazChannel" );
- $this->m->outputChanneled( "foo", "bazChannel" );
- $this->m->outputChanneled( "", "bazChannel" );
- $this->m->outputChanneled( "\nb", "bazChannel" );
- $this->m->outputChanneled( "a", "bazChannel" );
- $this->m->outputChanneled( "", "bazChannel" );
- $this->m->outputChanneled( "r", "bazChannel" );
- $this->assertOutputPrePostShutdown( "foo\nbar", True );
- }
-
- function testOutputChanneledWMultipleChannelsChannelChange() {
- $this->m->outputChanneled( "foo", "bazChannel" );
- $this->m->outputChanneled( "bar", "bazChannel" );
- $this->m->outputChanneled( "qux", "quuxChannel" );
- $this->m->outputChanneled( "corge", "bazChannel" );
- $this->assertOutputPrePostShutdown( "foobar\nqux\ncorge", True );
- }
-
- function testOutputChanneledWMultipleChannelsChannelChangeEnclosedNull() {
- $this->m->outputChanneled( "foo", "bazChannel" );
- $this->m->outputChanneled( "bar", null );
- $this->m->outputChanneled( "qux", null );
- $this->m->outputChanneled( "corge", "bazChannel" );
- $this->assertOutputPrePostShutdown( "foo\nbar\nqux\ncorge", True );
- }
-
- function testOutputChanneledWMultipleChannelsChannelAfterNullChange() {
- $this->m->outputChanneled( "foo", "bazChannel" );
- $this->m->outputChanneled( "bar", null );
- $this->m->outputChanneled( "qux", null );
- $this->m->outputChanneled( "corge", "quuxChannel" );
- $this->assertOutputPrePostShutdown( "foo\nbar\nqux\ncorge", True );
- }
-
- function testOutputChanneledWAndWOChannelStringStartWO() {
- $this->m->outputChanneled( "foo" );
- $this->m->outputChanneled( "bar", "bazChannel" );
- $this->m->outputChanneled( "qux" );
- $this->m->outputChanneled( "quux", "bazChannel" );
- $this->assertOutputPrePostShutdown( "foo\nbar\nqux\nquux", True );
- }
-
- function testOutputChanneledWAndWOChannelStringStartW() {
- $this->m->outputChanneled( "foo", "bazChannel" );
- $this->m->outputChanneled( "bar" );
- $this->m->outputChanneled( "qux", "bazChannel" );
- $this->m->outputChanneled( "quux" );
- $this->assertOutputPrePostShutdown( "foo\nbar\nqux\nquux\n", False );
- }
-
- function testOutputChanneledWChannelTypeSwitch() {
- $this->m->outputChanneled( "foo", 1 );
- $this->m->outputChanneled( "bar", 1.0 );
- $this->assertOutputPrePostShutdown( "foo\nbar", True );
- }
-
- function testOutputChanneledWOChannelIntermittentEmpty() {
- $this->m->outputChanneled( "foo" );
- $this->m->outputChanneled( "" );
- $this->m->outputChanneled( "bar" );
- $this->assertOutputPrePostShutdown( "foo\n\nbar\n", False );
- }
-
- function testOutputChanneledWOChannelIntermittentFalse() {
- $this->m->outputChanneled( "foo" );
- $this->m->outputChanneled( false );
- $this->m->outputChanneled( "bar" );
- $this->assertOutputPrePostShutdown( "foo\nbar\n", False );
- }
-
- function testOutputChanneledWNullChannelIntermittentEmpty() {
- $this->m->outputChanneled( "foo", null );
- $this->m->outputChanneled( "", null );
- $this->m->outputChanneled( "bar", null );
- $this->assertOutputPrePostShutdown( "foo\n\nbar\n", False );
- }
-
- function testOutputChanneledWNullChannelIntermittentFalse() {
- $this->m->outputChanneled( "foo", null );
- $this->m->outputChanneled( false, null );
- $this->m->outputChanneled( "bar", null );
- $this->assertOutputPrePostShutdown( "foo\nbar\n", False );
- }
-
- function testOutputChanneledWChannelIntermittentEmpty() {
- $this->m->outputChanneled( "foo", "bazChannel" );
- $this->m->outputChanneled( "", "bazChannel" );
- $this->m->outputChanneled( "bar", "bazChannel" );
- $this->assertOutputPrePostShutdown( "foobar", True );
- }
-
- function testOutputChanneledWChannelIntermittentFalse() {
- $this->m->outputChanneled( "foo", "bazChannel" );
- $this->m->outputChanneled( false, "bazChannel" );
- $this->m->outputChanneled( "bar", "bazChannel" );
- $this->assertOutputPrePostShutdown( "foo\nbar", True );
- }
-
- function testCleanupChanneledClean() {
- $this->m->cleanupChanneled();
- $this->assertOutputPrePostShutdown( "", False );
- }
-
- function testCleanupChanneledAfterOutput() {
- $this->m->output( "foo" );
- $this->m->cleanupChanneled();
- $this->assertOutputPrePostShutdown( "foo", False );
- }
-
- function testCleanupChanneledAfterOutputWNullChannel() {
- $this->m->output( "foo", null );
- $this->m->cleanupChanneled();
- $this->assertOutputPrePostShutdown( "foo", False );
- }
-
- function testCleanupChanneledAfterOutputWChannel() {
- $this->m->output( "foo", "bazChannel" );
- $this->m->cleanupChanneled();
- $this->assertOutputPrePostShutdown( "foo\n", False );
- }
-
- function testCleanupChanneledAfterNLOutput() {
- $this->m->output( "foo\n" );
- $this->m->cleanupChanneled();
- $this->assertOutputPrePostShutdown( "foo\n", False );
- }
-
- function testCleanupChanneledAfterNLOutputWNullChannel() {
- $this->m->output( "foo\n", null );
- $this->m->cleanupChanneled();
- $this->assertOutputPrePostShutdown( "foo\n", False );
- }
-
- function testCleanupChanneledAfterNLOutputWChannel() {
- $this->m->output( "foo\n", "bazChannel" );
- $this->m->cleanupChanneled();
- $this->assertOutputPrePostShutdown( "foo\n", False );
- }
-
- function testCleanupChanneledAfterOutputChanneledWOChannel() {
- $this->m->outputChanneled( "foo" );
- $this->m->cleanupChanneled();
- $this->assertOutputPrePostShutdown( "foo\n", False );
- }
-
- function testCleanupChanneledAfterOutputChanneledWNullChannel() {
- $this->m->outputChanneled( "foo", null );
- $this->m->cleanupChanneled();
- $this->assertOutputPrePostShutdown( "foo\n", False );
- }
-
- function testCleanupChanneledAfterOutputChanneledWChannel() {
- $this->m->outputChanneled( "foo", "bazChannel" );
- $this->m->cleanupChanneled();
- $this->assertOutputPrePostShutdown( "foo\n", False );
- }
-
- function testMultipleMaintenanceObjectsInteractionOutput() {
- $m2 = new MaintenanceFixup( $this );
-
- $this->m->output( "foo" );
- $m2->output( "bar" );
-
- $this->assertEquals( "foobar", $this->getActualOutput(),
- "Output before shutdown simulation (m2)" );
- $m2->simulateShutdown();
- $this->assertOutputPrePostShutdown( "foobar", False );
- }
-
- function testMultipleMaintenanceObjectsInteractionOutputWNullChannel() {
- $m2 = new MaintenanceFixup( $this );
-
- $this->m->output( "foo", null );
- $m2->output( "bar", null );
-
- $this->assertEquals( "foobar", $this->getActualOutput(),
- "Output before shutdown simulation (m2)" );
- $m2->simulateShutdown();
- $this->assertOutputPrePostShutdown( "foobar", False );
- }
-
- function testMultipleMaintenanceObjectsInteractionOutputWChannel() {
- $m2 = new MaintenanceFixup( $this );
-
- $this->m->output( "foo", "bazChannel" );
- $m2->output( "bar", "bazChannel" );
-
- $this->assertEquals( "foobar", $this->getActualOutput(),
- "Output before shutdown simulation (m2)" );
- $m2->simulateShutdown();
- $this->assertOutputPrePostShutdown( "foobar\n", True );
- }
-
- function testMultipleMaintenanceObjectsInteractionOutputWNullChannelNL() {
- $m2 = new MaintenanceFixup( $this );
-
- $this->m->output( "foo\n", null );
- $m2->output( "bar\n", null );
-
- $this->assertEquals( "foo\nbar\n", $this->getActualOutput(),
- "Output before shutdown simulation (m2)" );
- $m2->simulateShutdown();
- $this->assertOutputPrePostShutdown( "foo\nbar\n", False );
- }
-
- function testMultipleMaintenanceObjectsInteractionOutputWChannelNL() {
- $m2 = new MaintenanceFixup( $this );
-
- $this->m->output( "foo\n", "bazChannel" );
- $m2->output( "bar\n", "bazChannel" );
-
- $this->assertEquals( "foobar", $this->getActualOutput(),
- "Output before shutdown simulation (m2)" );
- $m2->simulateShutdown();
- $this->assertOutputPrePostShutdown( "foobar\n", True );
- }
-
- function testMultipleMaintenanceObjectsInteractionOutputChanneled() {
- $m2 = new MaintenanceFixup( $this );
-
- $this->m->outputChanneled( "foo" );
- $m2->outputChanneled( "bar" );
-
- $this->assertEquals( "foo\nbar\n", $this->getActualOutput(),
- "Output before shutdown simulation (m2)" );
- $m2->simulateShutdown();
- $this->assertOutputPrePostShutdown( "foo\nbar\n", False );
- }
-
- function testMultipleMaintenanceObjectsInteractionOutputChanneledWNullChannel() {
- $m2 = new MaintenanceFixup( $this );
-
- $this->m->outputChanneled( "foo", null );
- $m2->outputChanneled( "bar", null );
-
- $this->assertEquals( "foo\nbar\n", $this->getActualOutput(),
- "Output before shutdown simulation (m2)" );
- $m2->simulateShutdown();
- $this->assertOutputPrePostShutdown( "foo\nbar\n", False );
- }
-
- function testMultipleMaintenanceObjectsInteractionOutputChanneledWChannel() {
- $m2 = new MaintenanceFixup( $this );
-
- $this->m->outputChanneled( "foo", "bazChannel" );
- $m2->outputChanneled( "bar", "bazChannel" );
-
- $this->assertEquals( "foobar", $this->getActualOutput(),
- "Output before shutdown simulation (m2)" );
- $m2->simulateShutdown();
- $this->assertOutputPrePostShutdown( "foobar\n", True );
- }
-
- function testMultipleMaintenanceObjectsInteractionCleanupChanneledWChannel() {
- $m2 = new MaintenanceFixup( $this );
-
- $this->m->outputChanneled( "foo", "bazChannel" );
- $m2->outputChanneled( "bar", "bazChannel" );
-
- $this->assertEquals( "foobar", $this->getActualOutput(),
- "Output before first cleanup" );
- $this->m->cleanupChanneled();
- $this->assertEquals( "foobar\n", $this->getActualOutput(),
- "Output after first cleanup" );
- $m2->cleanupChanneled();
- $this->assertEquals( "foobar\n\n", $this->getActualOutput(),
- "Output after second cleanup" );
-
- $m2->simulateShutdown();
- $this->assertOutputPrePostShutdown( "foobar\n\n", False );
- }
-
-
-}
\ No newline at end of file
diff --git a/tests/phpunit/maintenance/backupPrefetchTest.php b/tests/phpunit/maintenance/backupPrefetchTest.php
deleted file mode 100644
index 8ff85574..00000000
--- a/tests/phpunit/maintenance/backupPrefetchTest.php
+++ /dev/null
@@ -1,270 +0,0 @@
-dump !== null ) {
- $this->dump->close();
- }
-
- // Bug 37458, parent teardown need to be done after closing the
- // dump or it might cause some permissions errors.
- parent::tearDown();
- }
-
- /**
- * asserts that a prefetch yields an expected string
- *
- * @param $expected string|null: the exepcted result of the prefetch
- * @param $page int: the page number to prefetch the text for
- * @param $revision int: the revision number to prefetch the text for
- */
- private function assertPrefetchEquals( $expected, $page, $revision ) {
- $this->assertEquals( $expected, $this->dump->prefetch( $page, $revision ),
- "Prefetch of page $page revision $revision" );
-
- }
-
- function testSequential() {
- $fname = $this->setUpPrefetch();
- $this->dump = new BaseDump( $fname );
-
- $this->assertPrefetchEquals( "BackupDumperTestP1Text1", 1, 1 );
- $this->assertPrefetchEquals( "BackupDumperTestP2Text1", 2, 2 );
- $this->assertPrefetchEquals( "BackupDumperTestP2Text4 some additional Text", 2, 5 );
- $this->assertPrefetchEquals( "Talk about BackupDumperTestP1 Text1", 4, 8 );
- }
-
- function testSynchronizeRevisionMissToRevision() {
- $fname = $this->setUpPrefetch();
- $this->dump = new BaseDump( $fname );
-
- $this->assertPrefetchEquals( "BackupDumperTestP2Text1", 2, 2 );
- $this->assertPrefetchEquals( null, 2, 3 );
- $this->assertPrefetchEquals( "BackupDumperTestP2Text4 some additional Text", 2, 5 );
- }
-
- function testSynchronizeRevisionMissToPage() {
- $fname = $this->setUpPrefetch();
- $this->dump = new BaseDump( $fname );
-
- $this->assertPrefetchEquals( "BackupDumperTestP2Text1", 2, 2 );
- $this->assertPrefetchEquals( null, 2, 40 );
- $this->assertPrefetchEquals( "Talk about BackupDumperTestP1 Text1", 4, 8 );
- }
-
- function testSynchronizePageMiss() {
- $fname = $this->setUpPrefetch();
- $this->dump = new BaseDump( $fname );
-
- $this->assertPrefetchEquals( "BackupDumperTestP2Text1", 2, 2 );
- $this->assertPrefetchEquals( null, 3, 40 );
- $this->assertPrefetchEquals( "Talk about BackupDumperTestP1 Text1", 4, 8 );
- }
-
- function testPageMissAtEnd() {
- $fname = $this->setUpPrefetch();
- $this->dump = new BaseDump( $fname );
-
- $this->assertPrefetchEquals( "BackupDumperTestP2Text1", 2, 2 );
- $this->assertPrefetchEquals( null, 6, 40 );
- }
-
- function testRevisionMissAtEnd() {
- $fname = $this->setUpPrefetch();
- $this->dump = new BaseDump( $fname );
-
- $this->assertPrefetchEquals( "BackupDumperTestP2Text1", 2, 2 );
- $this->assertPrefetchEquals( null, 4, 40 );
- }
-
- function testSynchronizePageMissAtStart() {
- $fname = $this->setUpPrefetch();
- $this->dump = new BaseDump( $fname );
-
- $this->assertPrefetchEquals( null, 0, 2 );
- $this->assertPrefetchEquals( "BackupDumperTestP2Text1", 2, 2 );
- }
-
- function testSynchronizeRevisionMissAtStart() {
- $fname = $this->setUpPrefetch();
- $this->dump = new BaseDump( $fname );
-
- $this->assertPrefetchEquals( null, 1, -2 );
- $this->assertPrefetchEquals( "BackupDumperTestP2Text1", 2, 2 );
- }
-
- function testSequentialAcrossFiles() {
- $fname1 = $this->setUpPrefetch( array( 1 ) );
- $fname2 = $this->setUpPrefetch( array( 2, 4 ) );
- $this->dump = new BaseDump( $fname1 . ";" . $fname2 );
-
- $this->assertPrefetchEquals( "BackupDumperTestP1Text1", 1, 1 );
- $this->assertPrefetchEquals( "BackupDumperTestP2Text1", 2, 2 );
- $this->assertPrefetchEquals( "BackupDumperTestP2Text4 some additional Text", 2, 5 );
- $this->assertPrefetchEquals( "Talk about BackupDumperTestP1 Text1", 4, 8 );
- }
-
- function testSynchronizeSkipAcrossFile() {
- $fname1 = $this->setUpPrefetch( array( 1 ) );
- $fname2 = $this->setUpPrefetch( array( 2 ) );
- $fname3 = $this->setUpPrefetch( array( 4 ) );
- $this->dump = new BaseDump( $fname1 . ";" . $fname2 . ";" . $fname3 );
-
- $this->assertPrefetchEquals( "BackupDumperTestP1Text1", 1, 1 );
- $this->assertPrefetchEquals( "Talk about BackupDumperTestP1 Text1", 4, 8 );
- }
-
- function testSynchronizeMissInWholeFirstFile() {
- $fname1 = $this->setUpPrefetch( array( 1 ) );
- $fname2 = $this->setUpPrefetch( array( 2 ) );
- $this->dump = new BaseDump( $fname1 . ";" . $fname2 );
-
- $this->assertPrefetchEquals( "BackupDumperTestP2Text1", 2, 2 );
- }
-
-
- /**
- * Constructs a temporary file that can be used for prefetching
- *
- * The temporary file is removed by DumpBackup upon tearDown.
- *
- * @param $requested_pages Array The indices of the page parts that should
- * go into the prefetch file. 1,2,4 are available.
- * @return String The file name of the created temporary file
- */
- private function setUpPrefetch( $requested_pages = array( 1, 2, 4 ) ) {
- // The file name, where we store the prepared prefetch file
- $fname = $this->getNewTempFile();
-
- // The header of every prefetch file
- $header = '
-
- wikisvn
- http://localhost/wiki-svn/index.php/Main_Page
- MediaWiki 1.20alpha
- first-letter
-
- Media
- Special
-
- Talk
- User
- User talk
- Wikisvn
- Wikisvn talk
- File
- File talk
- MediaWiki
- MediaWiki talk
- Template
- Template talk
- Help
- Help talk
- Category
- Category talk
-
-
-';
-
-
- // An array holding the pages that are available for prefetch
- $available_pages = array();
-
- // Simple plain page
- $available_pages[1] = '
- BackupDumperTestP1
- 0
- 1
-
- 1
- 2012-04-01T16:46:05Z
-
- 127.0.0.1
-
- BackupDumperTestP1Summary1
- 0bolhl6ol7i6x0e7yq91gxgaan39j87
- BackupDumperTestP1Text1
-
-
-';
- // Page with more than one revisions. Hole in rev ids.
- $available_pages[2] = '
- BackupDumperTestP2
- 0
- 2
-
- 2
- 2012-04-01T16:46:05Z
-
- 127.0.0.1
-
- BackupDumperTestP2Summary1
- jprywrymfhysqllua29tj3sc7z39dl2
- BackupDumperTestP2Text1
-
-
- 5
- 2
- 2012-04-01T16:46:05Z
-
- 127.0.0.1
-
- BackupDumperTestP2Summary4 extra
- 6o1ciaxa6pybnqprmungwofc4lv00wv
- BackupDumperTestP2Text4 some additional Text
-
-
-';
- // Page with id higher than previous id + 1
- $available_pages[4] = '
- Talk:BackupDumperTestP1
- 1
- 4
-
- 8
- 2012-04-01T16:46:05Z
-
- 127.0.0.1
-
- Talk BackupDumperTestP1 Summary1
- nktofwzd0tl192k3zfepmlzxoax1lpe
- Talk about BackupDumperTestP1 Text1
-
-
-';
-
- // The common ending for all files
- $tail = '
-';
-
- // Putting together the content of the prefetch files
- $content = $header;
- foreach ( $requested_pages as $i ) {
- $this->assertTrue( array_key_exists( $i, $available_pages ),
- "Check for availability of requested page " . $i );
- $content .= $available_pages[ $i ];
- }
- $content .= $tail;
-
- $this->assertEquals( strlen( $content ), file_put_contents(
- $fname, $content ), "Length of prepared prefetch" );
-
- return $fname;
- }
-
-}
diff --git a/tests/phpunit/maintenance/backupTextPassTest.php b/tests/phpunit/maintenance/backupTextPassTest.php
deleted file mode 100644
index a0bbadf9..00000000
--- a/tests/phpunit/maintenance/backupTextPassTest.php
+++ /dev/null
@@ -1,563 +0,0 @@
-tablesUsed[] = 'page';
- $this->tablesUsed[] = 'revision';
- $this->tablesUsed[] = 'text';
-
- try {
- // Simple page
- $title = Title::newFromText( 'BackupDumperTestP1' );
- $page = WikiPage::factory( $title );
- list( $this->revId1_1, $this->textId1_1 ) = $this->addRevision( $page,
- "BackupDumperTestP1Text1", "BackupDumperTestP1Summary1" );
- $this->pageId1 = $page->getId();
-
- // Page with more than one revision
- $title = Title::newFromText( 'BackupDumperTestP2' );
- $page = WikiPage::factory( $title );
- list( $this->revId2_1, $this->textId2_1 ) = $this->addRevision( $page,
- "BackupDumperTestP2Text1", "BackupDumperTestP2Summary1" );
- list( $this->revId2_2, $this->textId2_2 ) = $this->addRevision( $page,
- "BackupDumperTestP2Text2", "BackupDumperTestP2Summary2" );
- list( $this->revId2_3, $this->textId2_3 ) = $this->addRevision( $page,
- "BackupDumperTestP2Text3", "BackupDumperTestP2Summary3" );
- list( $this->revId2_4, $this->textId2_4 ) = $this->addRevision( $page,
- "BackupDumperTestP2Text4 some additional Text ",
- "BackupDumperTestP2Summary4 extra " );
- $this->pageId2 = $page->getId();
-
- // Deleted page.
- $title = Title::newFromText( 'BackupDumperTestP3' );
- $page = WikiPage::factory( $title );
- list( $this->revId3_1, $this->textId3_1 ) = $this->addRevision( $page,
- "BackupDumperTestP3Text1", "BackupDumperTestP2Summary1" );
- list( $this->revId3_2, $this->textId3_2 ) = $this->addRevision( $page,
- "BackupDumperTestP3Text2", "BackupDumperTestP2Summary2" );
- $this->pageId3 = $page->getId();
- $page->doDeleteArticle( "Testing ;)" );
-
- // Page from non-default namespace
- $title = Title::newFromText( 'BackupDumperTestP1', NS_TALK );
- $page = WikiPage::factory( $title );
- list( $this->revId4_1, $this->textId4_1 ) = $this->addRevision( $page,
- "Talk about BackupDumperTestP1 Text1",
- "Talk BackupDumperTestP1 Summary1" );
- $this->pageId4 = $page->getId();
- } catch ( Exception $e ) {
- // We'd love to pass $e directly. However, ... see
- // documentation of exceptionFromAddDBData in
- // DumpTestCase
- $this->exceptionFromAddDBData = $e;
- }
-
- }
-
- public function setUp() {
- parent::setUp();
-
- // Since we will restrict dumping by page ranges (to allow
- // working tests, even if the db gets prepopulated by a base
- // class), we have to assert, that the page id are consecutively
- // increasing
- $this->assertEquals(
- array( $this->pageId2, $this->pageId3, $this->pageId4 ),
- array( $this->pageId1 + 1, $this->pageId2 + 1, $this->pageId3 + 1 ),
- "Page ids increasing without holes" );
-
- }
-
- function testPlain() {
- // Setting up the dump
- $nameStub = $this->setUpStub();
- $nameFull = $this->getNewTempFile();
- $dumper = new TextPassDumper( array ( "--stub=file:" . $nameStub,
- "--output=file:" . $nameFull ) );
- $dumper->reporting = false;
- $dumper->setDb( $this->db );
-
- // Performing the dump
- $dumper->dump( WikiExporter::FULL, WikiExporter::TEXT );
-
- // Checking for correctness of the dumped data
- $this->assertDumpStart( $nameFull );
-
- // Page 1
- $this->assertPageStart( $this->pageId1, NS_MAIN, "BackupDumperTestP1" );
- $this->assertRevision( $this->revId1_1, "BackupDumperTestP1Summary1",
- $this->textId1_1, false, "0bolhl6ol7i6x0e7yq91gxgaan39j87",
- "BackupDumperTestP1Text1" );
- $this->assertPageEnd();
-
- // Page 2
- $this->assertPageStart( $this->pageId2, NS_MAIN, "BackupDumperTestP2" );
- $this->assertRevision( $this->revId2_1, "BackupDumperTestP2Summary1",
- $this->textId2_1, false, "jprywrymfhysqllua29tj3sc7z39dl2",
- "BackupDumperTestP2Text1" );
- $this->assertRevision( $this->revId2_2, "BackupDumperTestP2Summary2",
- $this->textId2_2, false, "b7vj5ks32po5m1z1t1br4o7scdwwy95",
- "BackupDumperTestP2Text2", $this->revId2_1 );
- $this->assertRevision( $this->revId2_3, "BackupDumperTestP2Summary3",
- $this->textId2_3, false, "jfunqmh1ssfb8rs43r19w98k28gg56r",
- "BackupDumperTestP2Text3", $this->revId2_2 );
- $this->assertRevision( $this->revId2_4, "BackupDumperTestP2Summary4 extra",
- $this->textId2_4, false, "6o1ciaxa6pybnqprmungwofc4lv00wv",
- "BackupDumperTestP2Text4 some additional Text", $this->revId2_3 );
- $this->assertPageEnd();
-
- // Page 3
- // -> Page is marked deleted. Hence not visible
-
- // Page 4
- $this->assertPageStart( $this->pageId4, NS_TALK, "Talk:BackupDumperTestP1" );
- $this->assertRevision( $this->revId4_1, "Talk BackupDumperTestP1 Summary1",
- $this->textId4_1, false, "nktofwzd0tl192k3zfepmlzxoax1lpe",
- "Talk about BackupDumperTestP1 Text1" );
- $this->assertPageEnd();
-
- $this->assertDumpEnd();
- }
-
- function testPrefetchPlain() {
- // The mapping between ids and text, for the hits of the prefetch mock
- $prefetchMap = array(
- array( $this->pageId1, $this->revId1_1, "Prefetch_________1Text1" ),
- array( $this->pageId2, $this->revId2_3, "Prefetch_________2Text3" )
- );
-
- // The mock itself
- $prefetchMock = $this->getMock( 'BaseDump', array( 'prefetch' ), array(), '', FALSE );
- $prefetchMock->expects( $this->exactly( 6 ) )
- ->method( 'prefetch' )
- ->will( $this->returnValueMap( $prefetchMap ) );
-
- // Setting up of the dump
- $nameStub = $this->setUpStub();
- $nameFull = $this->getNewTempFile();
- $dumper = new TextPassDumper( array ( "--stub=file:"
- . $nameStub, "--output=file:" . $nameFull ) );
- $dumper->prefetch = $prefetchMock;
- $dumper->reporting = false;
- $dumper->setDb( $this->db );
-
- // Performing the dump
- $dumper->dump( WikiExporter::FULL, WikiExporter::TEXT );
-
- // Checking for correctness of the dumped data
- $this->assertDumpStart( $nameFull );
-
- // Page 1
- $this->assertPageStart( $this->pageId1, NS_MAIN, "BackupDumperTestP1" );
- // Prefetch kicks in. This is still the SHA-1 of the original text,
- // But the actual text (with different SHA-1) comes from prefetch.
- $this->assertRevision( $this->revId1_1, "BackupDumperTestP1Summary1",
- $this->textId1_1, false, "0bolhl6ol7i6x0e7yq91gxgaan39j87",
- "Prefetch_________1Text1" );
- $this->assertPageEnd();
-
- // Page 2
- $this->assertPageStart( $this->pageId2, NS_MAIN, "BackupDumperTestP2" );
- $this->assertRevision( $this->revId2_1, "BackupDumperTestP2Summary1",
- $this->textId2_1, false, "jprywrymfhysqllua29tj3sc7z39dl2",
- "BackupDumperTestP2Text1" );
- $this->assertRevision( $this->revId2_2, "BackupDumperTestP2Summary2",
- $this->textId2_2, false, "b7vj5ks32po5m1z1t1br4o7scdwwy95",
- "BackupDumperTestP2Text2", $this->revId2_1 );
- // Prefetch kicks in. This is still the SHA-1 of the original text,
- // But the actual text (with different SHA-1) comes from prefetch.
- $this->assertRevision( $this->revId2_3, "BackupDumperTestP2Summary3",
- $this->textId2_3, false, "jfunqmh1ssfb8rs43r19w98k28gg56r",
- "Prefetch_________2Text3", $this->revId2_2 );
- $this->assertRevision( $this->revId2_4, "BackupDumperTestP2Summary4 extra",
- $this->textId2_4, false, "6o1ciaxa6pybnqprmungwofc4lv00wv",
- "BackupDumperTestP2Text4 some additional Text", $this->revId2_3 );
- $this->assertPageEnd();
-
- // Page 3
- // -> Page is marked deleted. Hence not visible
-
- // Page 4
- $this->assertPageStart( $this->pageId4, NS_TALK, "Talk:BackupDumperTestP1" );
- $this->assertRevision( $this->revId4_1, "Talk BackupDumperTestP1 Summary1",
- $this->textId4_1, false, "nktofwzd0tl192k3zfepmlzxoax1lpe",
- "Talk about BackupDumperTestP1 Text1" );
- $this->assertPageEnd();
-
- $this->assertDumpEnd();
-
- }
-
- /**
- * Ensures that checkpoint dumps are used and written, by successively increasing the
- * stub size and dumping until the duration crosses a threshold.
- *
- * @param $checkpointFormat string: Either "file" for plain text or "gzip" for gzipped
- * checkpoint files.
- */
- private function checkpointHelper( $checkpointFormat = "file" ) {
- // Getting temporary names
- $nameStub = $this->getNewTempFile();
- $nameOutputDir = $this->getNewTempDirectory();
-
- $stderr = fopen( 'php://output', 'a' );
- if ( $stderr === FALSE ) {
- $this->fail( "Could not open stream for stderr" );
- }
-
- $iterations = 32; // We'll start with that many iterations of revisions in stub
- $lastDuration = 0;
- $minDuration = 2; // We want the dump to take at least this many seconds
- $checkpointAfter = 0.5; // Generate checkpoint after this many seconds
-
-
- // Until a dump takes at least $minDuration seconds, perform a dump and check
- // duration. If the dump did not take long enough increase the iteration
- // count, to generate a bigger stub file next time.
- while ( $lastDuration < $minDuration ) {
-
- // Setting up the dump
- wfRecursiveRemoveDir( $nameOutputDir );
- $this->assertTrue( wfMkdirParents( $nameOutputDir ),
- "Creating temporary output directory " );
- $this->setUpStub( $nameStub, $iterations );
- $dumper = new TextPassDumper( array ( "--stub=file:" . $nameStub,
- "--output=" . $checkpointFormat . ":" . $nameOutputDir . "/full",
- "--maxtime=1" /*This is in minutes. Fixup is below*/,
- "--checkpointfile=checkpoint-%s-%s.xml.gz" ) );
- $dumper->setDb( $this->db );
- $dumper->maxTimeAllowed = $checkpointAfter; // Patching maxTime from 1 minute
- $dumper->stderr = $stderr;
-
- // The actual dump and taking time
- $ts_before = microtime( true );
- $dumper->dump( WikiExporter::FULL, WikiExporter::TEXT );
- $ts_after = microtime( true );
- $lastDuration = $ts_after - $ts_before;
-
- // Handling increasing the iteration count for the stubs
- if ( $lastDuration < $minDuration ) {
- $old_iterations = $iterations;
- if ( $lastDuration > 0.2 ) {
- // lastDuration is big enough, to allow an educated guess
- $factor = ( $minDuration + 0.5 ) / $lastDuration;
- if ( ( $factor > 1.1 ) && ( $factor < 100 ) ) {
- // educated guess is reasonable
- $iterations = (int)( $iterations * $factor );
- }
- }
-
- if ( $old_iterations == $iterations ) {
- // Heuristics were not applied, so we just *2.
- $iterations *= 2;
- }
-
- $this->assertLessThan( 50000, $iterations,
- "Emergency stop against infinitely increasing iteration "
- . "count ( last duration: $lastDuration )" );
- }
- }
-
- // The dump (hopefully) did take long enough to produce more than one
- // checkpoint file.
- //
- // We now check all the checkpoint files for validity.
-
- $files = scandir( $nameOutputDir );
- $this->assertTrue( asort( $files ), "Sorting files in temporary directory" );
- $fileOpened = false;
- $lookingForPage = 1;
- $checkpointFiles = 0;
-
- // Each run of the following loop body tries to handle exactly 1 /page/ (not
- // iteration of stub content). $i is only increased after having treated page 4.
- for ( $i = 0 ; $i < $iterations ; ) {
-
- // 1. Assuring a file is opened and ready. Skipping across header if
- // necessary.
- if ( ! $fileOpened ) {
- $this->assertNotEmpty( $files, "No more existing dump files, "
- . "but not yet all pages found" );
- $fname = array_shift( $files );
- while ( $fname == "." || $fname == ".." ) {
- $this->assertNotEmpty( $files, "No more existing dump"
- . " files, but not yet all pages found" );
- $fname = array_shift( $files );
- }
- if ( $checkpointFormat == "gzip" ) {
- $this->gunzip( $nameOutputDir . "/" . $fname );
- }
- $this->assertDumpStart( $nameOutputDir . "/" . $fname );
- $fileOpened = true;
- $checkpointFiles++;
- }
-
- // 2. Performing a single page check
- switch ( $lookingForPage ) {
- case 1:
- // Page 1
- $this->assertPageStart( $this->pageId1 + $i * self::$numOfPages, NS_MAIN,
- "BackupDumperTestP1" );
- $this->assertRevision( $this->revId1_1 + $i * self::$numOfRevs, "BackupDumperTestP1Summary1",
- $this->textId1_1, false, "0bolhl6ol7i6x0e7yq91gxgaan39j87",
- "BackupDumperTestP1Text1" );
- $this->assertPageEnd();
-
- $lookingForPage = 2;
- break;
-
- case 2:
- // Page 2
- $this->assertPageStart( $this->pageId2 + $i * self::$numOfPages, NS_MAIN,
- "BackupDumperTestP2" );
- $this->assertRevision( $this->revId2_1 + $i * self::$numOfRevs, "BackupDumperTestP2Summary1",
- $this->textId2_1, false, "jprywrymfhysqllua29tj3sc7z39dl2",
- "BackupDumperTestP2Text1" );
- $this->assertRevision( $this->revId2_2 + $i * self::$numOfRevs, "BackupDumperTestP2Summary2",
- $this->textId2_2, false, "b7vj5ks32po5m1z1t1br4o7scdwwy95",
- "BackupDumperTestP2Text2", $this->revId2_1 + $i * self::$numOfRevs );
- $this->assertRevision( $this->revId2_3 + $i * self::$numOfRevs, "BackupDumperTestP2Summary3",
- $this->textId2_3, false, "jfunqmh1ssfb8rs43r19w98k28gg56r",
- "BackupDumperTestP2Text3", $this->revId2_2 + $i * self::$numOfRevs );
- $this->assertRevision( $this->revId2_4 + $i * self::$numOfRevs,
- "BackupDumperTestP2Summary4 extra",
- $this->textId2_4, false, "6o1ciaxa6pybnqprmungwofc4lv00wv",
- "BackupDumperTestP2Text4 some additional Text",
- $this->revId2_3 + $i * self::$numOfRevs );
- $this->assertPageEnd();
-
- $lookingForPage = 4;
- break;
-
- case 4:
- // Page 4
- $this->assertPageStart( $this->pageId4 + $i * self::$numOfPages, NS_TALK,
- "Talk:BackupDumperTestP1" );
- $this->assertRevision( $this->revId4_1 + $i * self::$numOfRevs,
- "Talk BackupDumperTestP1 Summary1",
- $this->textId4_1, false, "nktofwzd0tl192k3zfepmlzxoax1lpe",
- "Talk about BackupDumperTestP1 Text1" );
- $this->assertPageEnd();
-
- $lookingForPage = 1;
-
- // We dealt with the whole iteration.
- $i++;
- break;
-
- default:
- $this->fail( "Bad setting for lookingForPage ($lookingForPage)" );
- }
-
- // 3. Checking for the end of the current checkpoint file
- if ( $this->xml->nodeType == XMLReader::END_ELEMENT
- && $this->xml->name == "mediawiki" ) {
-
- $this->assertDumpEnd();
- $fileOpened = false;
- }
- }
-
- // Assuring we completely read all files ...
- $this->assertFalse( $fileOpened, "Currently read file still open?" );
- $this->assertEmpty( $files, "Remaining unchecked files" );
-
- // ... and have dealt with more than one checkpoint file
- $this->assertGreaterThan( 1, $checkpointFiles, "# of checkpoint files" );
-
- $this->expectETAOutput();
- }
-
- /**
- * @group large
- */
- function testCheckpointPlain() {
- $this->checkpointHelper();
- }
-
- /**
- * tests for working checkpoint generation in gzip format work.
- *
- * We keep this test in addition to the simpler self::testCheckpointPlain, as there
- * were once problems when the used sinks were DumpPipeOutputs.
- *
- * xmldumps-backup typically uses bzip2 instead of gzip. However, as bzip2 requires
- * PHP extensions, we go for gzip instead, which triggers the same relevant code
- * paths while still being testable on more systems.
- *
- * @group large
- */
- function testCheckpointGzip() {
- $this->checkpointHelper( "gzip" );
- }
-
-
- /**
- * Creates a stub file that is used for testing the text pass of dumps
- *
- * @param $fname string: (Optional) Absolute name of the file to write
- * the stub into. If this parameter is null, a new temporary
- * file is generated that is automatically removed upon
- * tearDown.
- * @param $iterations integer: (Optional) specifies how often the block
- * of 3 pages should go into the stub file. The page and
- * revision id increase further and further, while the text
- * id of the first iteration is reused. The pages and revision
- * of iteration > 1 have no corresponding representation in the
- * database.
- * @return string absolute filename of the stub
- */
- private function setUpStub( $fname = null, $iterations = 1 ) {
- if ( $fname === null ) {
- $fname = $this->getNewTempFile();
- }
- $header = '
-
- wikisvn
- http://localhost/wiki-svn/index.php/Main_Page
- MediaWiki 1.20alpha
- first-letter
-
- Media
- Special
-
- Talk
- User
- User talk
- Wikisvn
- Wikisvn talk
- File
- File talk
- MediaWiki
- MediaWiki talk
- Template
- Template talk
- Help
- Help talk
- Category
- Category talk
-
-
-';
- $tail = '
-';
-
- $content = $header;
- $iterations = intval( $iterations );
- for ( $i = 0; $i < $iterations; $i++ ) {
-
- $page1 = '
- BackupDumperTestP1
- 0
- ' . ( $this->pageId1 + $i * self::$numOfPages ) . '
-
- ' . ( $this->revId1_1 + $i * self::$numOfRevs ) . '
- 2012-04-01T16:46:05Z
-
- 127.0.0.1
-
- BackupDumperTestP1Summary1
- 0bolhl6ol7i6x0e7yq91gxgaan39j87
-
-
-
-';
- $page2 = '
- BackupDumperTestP2
- 0
- ' . ( $this->pageId2 + $i * self::$numOfPages ) . '
-
- ' . ( $this->revId2_1 + $i * self::$numOfRevs ) . '
- 2012-04-01T16:46:05Z
-
- 127.0.0.1
-
- BackupDumperTestP2Summary1
- jprywrymfhysqllua29tj3sc7z39dl2
-
-
-
- ' . ( $this->revId2_2 + $i * self::$numOfRevs ) . '
- ' . ( $this->revId2_1 + $i * self::$numOfRevs ) . '
- 2012-04-01T16:46:05Z
-
- 127.0.0.1
-
- BackupDumperTestP2Summary2
- b7vj5ks32po5m1z1t1br4o7scdwwy95
-
-
-
- ' . ( $this->revId2_3 + $i * self::$numOfRevs ) . '
- ' . ( $this->revId2_2 + $i * self::$numOfRevs ) . '
- 2012-04-01T16:46:05Z
-
- 127.0.0.1
-
- BackupDumperTestP2Summary3
- jfunqmh1ssfb8rs43r19w98k28gg56r
-
-
-
- ' . ( $this->revId2_4 + $i * self::$numOfRevs ) . '
- ' . ( $this->revId2_3 + $i * self::$numOfRevs ) . '
- 2012-04-01T16:46:05Z
-
- 127.0.0.1
-
- BackupDumperTestP2Summary4 extra
- 6o1ciaxa6pybnqprmungwofc4lv00wv
-
-
-
-';
- // page 3 not in stub
-
- $page4 = '
- Talk:BackupDumperTestP1
- 1
- ' . ( $this->pageId4 + $i * self::$numOfPages ) . '
-
- ' . ( $this->revId4_1 + $i * self::$numOfRevs ) . '
- 2012-04-01T16:46:05Z
-
- 127.0.0.1
-
- Talk BackupDumperTestP1 Summary1
- nktofwzd0tl192k3zfepmlzxoax1lpe
-
-
-
-';
- $content .= $page1 . $page2 . $page4;
- }
- $content .= $tail;
- $this->assertEquals( strlen( $content ), file_put_contents(
- $fname, $content ), "Length of prepared stub" );
- return $fname;
- }
-
-}
diff --git a/tests/phpunit/maintenance/backup_LogTest.php b/tests/phpunit/maintenance/backup_LogTest.php
deleted file mode 100644
index 8a8dea5a..00000000
--- a/tests/phpunit/maintenance/backup_LogTest.php
+++ /dev/null
@@ -1,227 +0,0 @@
-setPerformer( $user );
- $logEntry->setTarget( Title::newFromText( $title, $ns ) );
- if ( $comment !== null ) {
- $logEntry->setComment( $comment );
- }
- if ( $parameters !== null ) {
- $logEntry->setParameters( $parameters );
- }
- return $logEntry->insert();
- }
-
- function addDBData() {
- $this->tablesUsed[] = 'logging';
- $this->tablesUsed[] = 'user';
-
- try {
- $user1 = User::newFromName( 'BackupDumperLogUserA' );
- $this->userId1 = $user1->getId();
- if ( $this->userId1 === 0 ) {
- $user1->addToDatabase();
- $this->userId1 = $user1->getId();
- }
- $this->assertGreaterThan( 0, $this->userId1 );
-
- $user2 = User::newFromName( 'BackupDumperLogUserB' );
- $this->userId2 = $user2->getId();
- if ( $this->userId2 === 0 ) {
- $user2->addToDatabase();
- $this->userId2 = $user2->getId();
- }
- $this->assertGreaterThan( 0, $this->userId2 );
-
- $this->logId1 = $this->addLogEntry( 'type', 'subtype',
- $user1, NS_MAIN, "PageA" );
- $this->assertGreaterThan( 0, $this->logId1 );
-
- $this->logId2 = $this->addLogEntry( 'supress', 'delete',
- $user2, NS_TALK, "PageB", "SomeComment" );
- $this->assertGreaterThan( 0, $this->logId2 );
-
- $this->logId3 = $this->addLogEntry( 'move', 'delete',
- $user2, NS_MAIN, "PageA", "SomeOtherComment",
- array( 'key1' => 1, 3 => 'value3' ) );
- $this->assertGreaterThan( 0, $this->logId3 );
-
- } catch ( Exception $e ) {
- // We'd love to pass $e directly. However, ... see
- // documentation of exceptionFromAddDBData in
- // DumpTestCase
- $this->exceptionFromAddDBData = $e;
- }
-
- }
-
-
- /**
- * asserts that the xml reader is at the beginning of a log entry and skips over
- * it while analyzing it.
- *
- * @param $id int: id of the log entry
- * @param $user_name string: user name of the log entry's performer
- * @param $user_id int: user id of the log entry 's performer
- * @param $comment string|null: comment of the log entry. If null, the comment
- * text is ignored.
- * @param $type string: type of the log entry
- * @param $subtype string: subtype of the log entry
- * @param $title string: title of the log entry's target
- * @param $parameters array: (optional) unserialized data accompanying the log entry
- */
- private function assertLogItem( $id, $user_name, $user_id, $comment, $type,
- $subtype, $title, $parameters = array() ) {
-
- $this->assertNodeStart( "logitem" );
- $this->skipWhitespace();
-
- $this->assertTextNode( "id", $id );
- $this->assertTextNode( "timestamp", false );
-
- $this->assertNodeStart( "contributor" );
- $this->skipWhitespace();
- $this->assertTextNode( "username", $user_name );
- $this->assertTextNode( "id", $user_id );
- $this->assertNodeEnd( "contributor" );
- $this->skipWhitespace();
-
- if ( $comment !== null ) {
- $this->assertTextNode( "comment", $comment );
- }
- $this->assertTextNode( "type", $type );
- $this->assertTextNode( "action", $subtype );
- $this->assertTextNode( "logtitle", $title );
-
- $this->assertNodeStart( "params" );
- $parameters_xml = unserialize( $this->xml->value );
- $this->assertEquals( $parameters, $parameters_xml );
- $this->assertTrue( $this->xml->read(), "Skipping past processed text of params" );
- $this->assertNodeEnd( "params" );
- $this->skipWhitespace();
-
- $this->assertNodeEnd( "logitem" );
- $this->skipWhitespace();
- }
-
- function testPlain () {
- global $wgContLang;
-
- // Preparing the dump
- $fname = $this->getNewTempFile();
- $dumper = new BackupDumper( array ( "--output=file:" . $fname ) );
- $dumper->startId = $this->logId1;
- $dumper->endId = $this->logId3 + 1;
- $dumper->reporting = false;
- $dumper->setDb( $this->db );
-
- // Performing the dump
- $dumper->dump( WikiExporter::LOGS, WikiExporter::TEXT );
-
- // Analyzing the dumped data
- $this->assertDumpStart( $fname );
-
- $this->assertLogItem( $this->logId1, "BackupDumperLogUserA",
- $this->userId1, null, "type", "subtype", "PageA" );
-
- $this->assertNotNull( $wgContLang, "Content language object validation" );
- $namespace = $wgContLang->getNsText( NS_TALK );
- $this->assertInternalType( 'string', $namespace );
- $this->assertGreaterThan( 0, strlen( $namespace ) );
- $this->assertLogItem( $this->logId2, "BackupDumperLogUserB",
- $this->userId2, "SomeComment", "supress", "delete",
- $namespace . ":PageB" );
-
- $this->assertLogItem( $this->logId3, "BackupDumperLogUserB",
- $this->userId2, "SomeOtherComment", "move", "delete",
- "PageA", array( 'key1' => 1, 3 => 'value3' ) );
-
- $this->assertDumpEnd();
- }
-
- function testXmlDumpsBackupUseCaseLogging() {
- global $wgContLang;
-
- // Preparing the dump
- $fname = $this->getNewTempFile();
- $dumper = new BackupDumper( array ( "--output=gzip:" . $fname,
- "--reporting=2" ) );
- $dumper->startId = $this->logId1;
- $dumper->endId = $this->logId3 + 1;
- $dumper->setDb( $this->db );
-
- // xmldumps-backup demands reporting, although this is currently not
- // implemented in BackupDumper, when dumping logging data. We
- // nevertheless capture the output of the dump process already now,
- // to be able to alert (once dumping produces reports) that this test
- // needs updates.
- $dumper->stderr = fopen( 'php://output', 'a' );
- if ( $dumper->stderr === FALSE ) {
- $this->fail( "Could not open stream for stderr" );
- }
-
- // Performing the dump
- $dumper->dump( WikiExporter::LOGS, WikiExporter::TEXT );
-
- $this->assertTrue( fclose( $dumper->stderr ), "Closing stderr handle" );
-
- // Analyzing the dumped data
- $this->gunzip( $fname );
-
- $this->assertDumpStart( $fname );
-
- $this->assertLogItem( $this->logId1, "BackupDumperLogUserA",
- $this->userId1, null, "type", "subtype", "PageA" );
-
- $this->assertNotNull( $wgContLang, "Content language object validation" );
- $namespace = $wgContLang->getNsText( NS_TALK );
- $this->assertInternalType( 'string', $namespace );
- $this->assertGreaterThan( 0, strlen( $namespace ) );
- $this->assertLogItem( $this->logId2, "BackupDumperLogUserB",
- $this->userId2, "SomeComment", "supress", "delete",
- $namespace . ":PageB" );
-
- $this->assertLogItem( $this->logId3, "BackupDumperLogUserB",
- $this->userId2, "SomeOtherComment", "move", "delete",
- "PageA", array( 'key1' => 1, 3 => 'value3' ) );
-
- $this->assertDumpEnd();
-
- // Currently, no reporting is implemented. Alert via failure, once
- // this changes.
- // If reporting for log dumps has been implemented, please update
- // the following statement to catch good output
- $this->expectOutputString( '' );
- }
-
-}
diff --git a/tests/phpunit/maintenance/backup_PageTest.php b/tests/phpunit/maintenance/backup_PageTest.php
deleted file mode 100644
index 925e277d..00000000
--- a/tests/phpunit/maintenance/backup_PageTest.php
+++ /dev/null
@@ -1,389 +0,0 @@
-tablesUsed[] = 'page';
- $this->tablesUsed[] = 'revision';
- $this->tablesUsed[] = 'text';
-
- try {
- $title = Title::newFromText( 'BackupDumperTestP1' );
- $page = WikiPage::factory( $title );
- list( $this->revId1_1, $this->textId1_1 ) = $this->addRevision( $page,
- "BackupDumperTestP1Text1", "BackupDumperTestP1Summary1" );
- $this->pageId1 = $page->getId();
-
- $title = Title::newFromText( 'BackupDumperTestP2' );
- $page = WikiPage::factory( $title );
- list( $this->revId2_1, $this->textId2_1 ) = $this->addRevision( $page,
- "BackupDumperTestP2Text1", "BackupDumperTestP2Summary1" );
- list( $this->revId2_2, $this->textId2_2 ) = $this->addRevision( $page,
- "BackupDumperTestP2Text2", "BackupDumperTestP2Summary2" );
- list( $this->revId2_3, $this->textId2_3 ) = $this->addRevision( $page,
- "BackupDumperTestP2Text3", "BackupDumperTestP2Summary3" );
- list( $this->revId2_4, $this->textId2_4 ) = $this->addRevision( $page,
- "BackupDumperTestP2Text4 some additional Text ",
- "BackupDumperTestP2Summary4 extra " );
- $this->pageId2 = $page->getId();
-
- $title = Title::newFromText( 'BackupDumperTestP3' );
- $page = WikiPage::factory( $title );
- list( $this->revId3_1, $this->textId3_1 ) = $this->addRevision( $page,
- "BackupDumperTestP3Text1", "BackupDumperTestP2Summary1" );
- list( $this->revId3_2, $this->textId3_2 ) = $this->addRevision( $page,
- "BackupDumperTestP3Text2", "BackupDumperTestP2Summary2" );
- $this->pageId3 = $page->getId();
- $page->doDeleteArticle( "Testing ;)" );
-
- $title = Title::newFromText( 'BackupDumperTestP1', NS_TALK );
- $page = WikiPage::factory( $title );
- list( $this->revId4_1, $this->textId4_1 ) = $this->addRevision( $page,
- "Talk about BackupDumperTestP1 Text1",
- "Talk BackupDumperTestP1 Summary1" );
- $this->pageId4 = $page->getId();
- } catch ( Exception $e ) {
- // We'd love to pass $e directly. However, ... see
- // documentation of exceptionFromAddDBData in
- // DumpTestCase
- $this->exceptionFromAddDBData = $e;
- }
-
- }
-
- public function setUp() {
- parent::setUp();
-
- // Since we will restrict dumping by page ranges (to allow
- // working tests, even if the db gets prepopulated by a base
- // class), we have to assert, that the page id are consecutively
- // increasing
- $this->assertEquals(
- array( $this->pageId2, $this->pageId3, $this->pageId4 ),
- array( $this->pageId1 + 1, $this->pageId2 + 1, $this->pageId3 + 1 ),
- "Page ids increasing without holes" );
-
- }
-
- function testFullTextPlain () {
- // Preparing the dump
- $fname = $this->getNewTempFile();
- $dumper = new BackupDumper( array ( "--output=file:" . $fname ) );
- $dumper->startId = $this->pageId1;
- $dumper->endId = $this->pageId4 + 1;
- $dumper->reporting = false;
- $dumper->setDb( $this->db );
-
- // Performing the dump
- $dumper->dump( WikiExporter::FULL, WikiExporter::TEXT );
-
- // Checking the dumped data
- $this->assertDumpStart( $fname );
-
- // Page 1
- $this->assertPageStart( $this->pageId1, NS_MAIN, "BackupDumperTestP1" );
- $this->assertRevision( $this->revId1_1, "BackupDumperTestP1Summary1",
- $this->textId1_1, 23, "0bolhl6ol7i6x0e7yq91gxgaan39j87",
- "BackupDumperTestP1Text1" );
- $this->assertPageEnd();
-
- // Page 2
- $this->assertPageStart( $this->pageId2, NS_MAIN, "BackupDumperTestP2" );
- $this->assertRevision( $this->revId2_1, "BackupDumperTestP2Summary1",
- $this->textId2_1, 23, "jprywrymfhysqllua29tj3sc7z39dl2",
- "BackupDumperTestP2Text1" );
- $this->assertRevision( $this->revId2_2, "BackupDumperTestP2Summary2",
- $this->textId2_2, 23, "b7vj5ks32po5m1z1t1br4o7scdwwy95",
- "BackupDumperTestP2Text2", $this->revId2_1 );
- $this->assertRevision( $this->revId2_3, "BackupDumperTestP2Summary3",
- $this->textId2_3, 23, "jfunqmh1ssfb8rs43r19w98k28gg56r",
- "BackupDumperTestP2Text3", $this->revId2_2 );
- $this->assertRevision( $this->revId2_4, "BackupDumperTestP2Summary4 extra",
- $this->textId2_4, 44, "6o1ciaxa6pybnqprmungwofc4lv00wv",
- "BackupDumperTestP2Text4 some additional Text", $this->revId2_3 );
- $this->assertPageEnd();
-
- // Page 3
- // -> Page is marked deleted. Hence not visible
-
- // Page 4
- $this->assertPageStart( $this->pageId4, NS_TALK, "Talk:BackupDumperTestP1" );
- $this->assertRevision( $this->revId4_1, "Talk BackupDumperTestP1 Summary1",
- $this->textId4_1, 35, "nktofwzd0tl192k3zfepmlzxoax1lpe",
- "Talk about BackupDumperTestP1 Text1" );
- $this->assertPageEnd();
-
- $this->assertDumpEnd();
- }
-
- function testFullStubPlain () {
- // Preparing the dump
- $fname = $this->getNewTempFile();
- $dumper = new BackupDumper( array ( "--output=file:" . $fname ) );
- $dumper->startId = $this->pageId1;
- $dumper->endId = $this->pageId4 + 1;
- $dumper->reporting = false;
- $dumper->setDb( $this->db );
-
- // Performing the dump
- $dumper->dump( WikiExporter::FULL, WikiExporter::STUB );
-
- // Checking the dumped data
- $this->assertDumpStart( $fname );
-
- // Page 1
- $this->assertPageStart( $this->pageId1, NS_MAIN, "BackupDumperTestP1" );
- $this->assertRevision( $this->revId1_1, "BackupDumperTestP1Summary1",
- $this->textId1_1, 23, "0bolhl6ol7i6x0e7yq91gxgaan39j87" );
- $this->assertPageEnd();
-
- // Page 2
- $this->assertPageStart( $this->pageId2, NS_MAIN, "BackupDumperTestP2" );
- $this->assertRevision( $this->revId2_1, "BackupDumperTestP2Summary1",
- $this->textId2_1, 23, "jprywrymfhysqllua29tj3sc7z39dl2" );
- $this->assertRevision( $this->revId2_2, "BackupDumperTestP2Summary2",
- $this->textId2_2, 23, "b7vj5ks32po5m1z1t1br4o7scdwwy95", false, $this->revId2_1 );
- $this->assertRevision( $this->revId2_3, "BackupDumperTestP2Summary3",
- $this->textId2_3, 23, "jfunqmh1ssfb8rs43r19w98k28gg56r", false, $this->revId2_2 );
- $this->assertRevision( $this->revId2_4, "BackupDumperTestP2Summary4 extra",
- $this->textId2_4, 44, "6o1ciaxa6pybnqprmungwofc4lv00wv", false, $this->revId2_3 );
- $this->assertPageEnd();
-
- // Page 3
- // -> Page is marked deleted. Hence not visible
-
- // Page 4
- $this->assertPageStart( $this->pageId4, NS_TALK, "Talk:BackupDumperTestP1" );
- $this->assertRevision( $this->revId4_1, "Talk BackupDumperTestP1 Summary1",
- $this->textId4_1, 35, "nktofwzd0tl192k3zfepmlzxoax1lpe" );
- $this->assertPageEnd();
-
- $this->assertDumpEnd();
- }
-
- function testCurrentStubPlain () {
- // Preparing the dump
- $fname = $this->getNewTempFile();
- $dumper = new BackupDumper( array ( "--output=file:" . $fname ) );
- $dumper->startId = $this->pageId1;
- $dumper->endId = $this->pageId4 + 1;
- $dumper->reporting = false;
- $dumper->setDb( $this->db );
-
- // Performing the dump
- $dumper->dump( WikiExporter::CURRENT, WikiExporter::STUB );
-
- // Checking the dumped data
- $this->assertDumpStart( $fname );
-
- // Page 1
- $this->assertPageStart( $this->pageId1, NS_MAIN, "BackupDumperTestP1" );
- $this->assertRevision( $this->revId1_1, "BackupDumperTestP1Summary1",
- $this->textId1_1, 23, "0bolhl6ol7i6x0e7yq91gxgaan39j87" );
- $this->assertPageEnd();
-
- // Page 2
- $this->assertPageStart( $this->pageId2, NS_MAIN, "BackupDumperTestP2" );
- $this->assertRevision( $this->revId2_4, "BackupDumperTestP2Summary4 extra",
- $this->textId2_4, 44, "6o1ciaxa6pybnqprmungwofc4lv00wv", false, $this->revId2_3 );
- $this->assertPageEnd();
-
- // Page 3
- // -> Page is marked deleted. Hence not visible
-
- // Page 4
- $this->assertPageStart( $this->pageId4, NS_TALK, "Talk:BackupDumperTestP1" );
- $this->assertRevision( $this->revId4_1, "Talk BackupDumperTestP1 Summary1",
- $this->textId4_1, 35, "nktofwzd0tl192k3zfepmlzxoax1lpe" );
- $this->assertPageEnd();
-
- $this->assertDumpEnd();
- }
-
- function testCurrentStubGzip () {
- // Preparing the dump
- $fname = $this->getNewTempFile();
- $dumper = new BackupDumper( array ( "--output=gzip:" . $fname ) );
- $dumper->startId = $this->pageId1;
- $dumper->endId = $this->pageId4 + 1;
- $dumper->reporting = false;
- $dumper->setDb( $this->db );
-
- // Performing the dump
- $dumper->dump( WikiExporter::CURRENT, WikiExporter::STUB );
-
- // Checking the dumped data
- $this->gunzip( $fname );
- $this->assertDumpStart( $fname );
-
- // Page 1
- $this->assertPageStart( $this->pageId1, NS_MAIN, "BackupDumperTestP1" );
- $this->assertRevision( $this->revId1_1, "BackupDumperTestP1Summary1",
- $this->textId1_1, 23, "0bolhl6ol7i6x0e7yq91gxgaan39j87" );
- $this->assertPageEnd();
-
- // Page 2
- $this->assertPageStart( $this->pageId2, NS_MAIN, "BackupDumperTestP2" );
- $this->assertRevision( $this->revId2_4, "BackupDumperTestP2Summary4 extra",
- $this->textId2_4, 44, "6o1ciaxa6pybnqprmungwofc4lv00wv", false, $this->revId2_3 );
- $this->assertPageEnd();
-
- // Page 3
- // -> Page is marked deleted. Hence not visible
-
- // Page 4
- $this->assertPageStart( $this->pageId4, NS_TALK, "Talk:BackupDumperTestP1" );
- $this->assertRevision( $this->revId4_1, "Talk BackupDumperTestP1 Summary1",
- $this->textId4_1, 35, "nktofwzd0tl192k3zfepmlzxoax1lpe" );
- $this->assertPageEnd();
-
- $this->assertDumpEnd();
- }
-
-
-
- function testXmlDumpsBackupUseCase () {
- // xmldumps-backup typically performs a single dump that that writes
- // out three files
- // * gzipped stubs of everything (meta-history)
- // * gzipped stubs of latest revisions of all pages (meta-current)
- // * gzipped stubs of latest revisions of all pages of namespage 0
- // (articles)
- //
- // We reproduce such a setup with our mini fixture, although we omit
- // chunks, and all the other gimmicks of xmldumps-backup.
- //
- $fnameMetaHistory = $this->getNewTempFile();
- $fnameMetaCurrent = $this->getNewTempFile();
- $fnameArticles = $this->getNewTempFile();
-
- $dumper = new BackupDumper( array ( "--output=gzip:" . $fnameMetaHistory,
- "--output=gzip:" . $fnameMetaCurrent, "--filter=latest",
- "--output=gzip:" . $fnameArticles, "--filter=latest",
- "--filter=notalk", "--filter=namespace:!NS_USER",
- "--reporting=1000" ) );
- $dumper->startId = $this->pageId1;
- $dumper->endId = $this->pageId4 + 1;
- $dumper->setDb( $this->db );
-
- // xmldumps-backup uses reporting. We will not check the exact reported
- // message, as they are dependent on the processing power of the used
- // computer. We only check that reporting does not crash the dumping
- // and that something is reported
- $dumper->stderr = fopen( 'php://output', 'a' );
- if ( $dumper->stderr === FALSE ) {
- $this->fail( "Could not open stream for stderr" );
- }
-
- // Performing the dump
- $dumper->dump( WikiExporter::FULL, WikiExporter::STUB );
-
- $this->assertTrue( fclose( $dumper->stderr ), "Closing stderr handle" );
-
- // Checking meta-history -------------------------------------------------
-
- $this->gunzip( $fnameMetaHistory );
- $this->assertDumpStart( $fnameMetaHistory );
-
- // Page 1
- $this->assertPageStart( $this->pageId1, NS_MAIN, "BackupDumperTestP1" );
- $this->assertRevision( $this->revId1_1, "BackupDumperTestP1Summary1",
- $this->textId1_1, 23, "0bolhl6ol7i6x0e7yq91gxgaan39j87" );
- $this->assertPageEnd();
-
- // Page 2
- $this->assertPageStart( $this->pageId2, NS_MAIN, "BackupDumperTestP2" );
- $this->assertRevision( $this->revId2_1, "BackupDumperTestP2Summary1",
- $this->textId2_1, 23, "jprywrymfhysqllua29tj3sc7z39dl2" );
- $this->assertRevision( $this->revId2_2, "BackupDumperTestP2Summary2",
- $this->textId2_2, 23, "b7vj5ks32po5m1z1t1br4o7scdwwy95", false, $this->revId2_1 );
- $this->assertRevision( $this->revId2_3, "BackupDumperTestP2Summary3",
- $this->textId2_3, 23, "jfunqmh1ssfb8rs43r19w98k28gg56r", false, $this->revId2_2 );
- $this->assertRevision( $this->revId2_4, "BackupDumperTestP2Summary4 extra",
- $this->textId2_4, 44, "6o1ciaxa6pybnqprmungwofc4lv00wv", false, $this->revId2_3 );
- $this->assertPageEnd();
-
- // Page 3
- // -> Page is marked deleted. Hence not visible
-
- // Page 4
- $this->assertPageStart( $this->pageId4, NS_TALK, "Talk:BackupDumperTestP1" );
- $this->assertRevision( $this->revId4_1, "Talk BackupDumperTestP1 Summary1",
- $this->textId4_1, 35, "nktofwzd0tl192k3zfepmlzxoax1lpe" );
- $this->assertPageEnd();
-
- $this->assertDumpEnd();
-
- // Checking meta-current -------------------------------------------------
-
- $this->gunzip( $fnameMetaCurrent );
- $this->assertDumpStart( $fnameMetaCurrent );
-
- // Page 1
- $this->assertPageStart( $this->pageId1, NS_MAIN, "BackupDumperTestP1" );
- $this->assertRevision( $this->revId1_1, "BackupDumperTestP1Summary1",
- $this->textId1_1, 23, "0bolhl6ol7i6x0e7yq91gxgaan39j87" );
- $this->assertPageEnd();
-
- // Page 2
- $this->assertPageStart( $this->pageId2, NS_MAIN, "BackupDumperTestP2" );
- $this->assertRevision( $this->revId2_4, "BackupDumperTestP2Summary4 extra",
- $this->textId2_4, 44, "6o1ciaxa6pybnqprmungwofc4lv00wv", false, $this->revId2_3 );
- $this->assertPageEnd();
-
- // Page 3
- // -> Page is marked deleted. Hence not visible
-
- // Page 4
- $this->assertPageStart( $this->pageId4, NS_TALK, "Talk:BackupDumperTestP1" );
- $this->assertRevision( $this->revId4_1, "Talk BackupDumperTestP1 Summary1",
- $this->textId4_1, 35, "nktofwzd0tl192k3zfepmlzxoax1lpe" );
- $this->assertPageEnd();
-
- $this->assertDumpEnd();
-
- // Checking articles -------------------------------------------------
-
- $this->gunzip( $fnameArticles );
- $this->assertDumpStart( $fnameArticles );
-
- // Page 1
- $this->assertPageStart( $this->pageId1, NS_MAIN, "BackupDumperTestP1" );
- $this->assertRevision( $this->revId1_1, "BackupDumperTestP1Summary1",
- $this->textId1_1, 23, "0bolhl6ol7i6x0e7yq91gxgaan39j87" );
- $this->assertPageEnd();
-
- // Page 2
- $this->assertPageStart( $this->pageId2, NS_MAIN, "BackupDumperTestP2" );
- $this->assertRevision( $this->revId2_4, "BackupDumperTestP2Summary4 extra",
- $this->textId2_4, 44, "6o1ciaxa6pybnqprmungwofc4lv00wv", false, $this->revId2_3 );
- $this->assertPageEnd();
-
- // Page 3
- // -> Page is marked deleted. Hence not visible
-
- // Page 4
- // -> Page is not in NS_MAIN. Hence not visible
-
- $this->assertDumpEnd();
-
- $this->expectETAOutput();
- }
-
-
-
-}
diff --git a/tests/phpunit/maintenance/fetchTextTest.php b/tests/phpunit/maintenance/fetchTextTest.php
deleted file mode 100644
index e7ffa01c..00000000
--- a/tests/phpunit/maintenance/fetchTextTest.php
+++ /dev/null
@@ -1,243 +0,0 @@
- 0 );
-
-
-
- /**
- * Data for the fake stdin
- *
- * @param $stdin String The string to be used instead of stdin
- */
- function mockStdin( $stdin )
- {
- $this->mockStdinText = $stdin;
- $this->mockSetUp = True;
- }
-
- /**
- * Gets invocation counters for mocked methods.
- *
- * @return Array An array, whose keys are function names. The corresponding values
- * denote the number of times the function has been invoked.
- */
- function mockGetInvocations()
- {
- return $this->mockInvocations;
- }
-
- // -----------------------------------------------------------------
- // Mocked functions from FetchText follow.
-
- function getStdin( $len = null )
- {
- $this->mockInvocations['getStdin']++;
- if ( $len !== null ) {
- throw new PHPUnit_Framework_ExpectationFailedException(
- "Tried to get stdin with non null parameter" );
- }
-
- if ( ! $this->mockSetUp ) {
- throw new PHPUnit_Framework_ExpectationFailedException(
- "Tried to get stdin before setting up rerouting" );
- }
-
- return fopen( 'data://text/plain,' . $this->mockStdinText, 'r' );
- }
-
-}
-
-/**
- * TestCase for FetchText
- *
- * @group Database
- * @group Dump
- */
-class FetchTextTest extends MediaWikiTestCase {
-
- // We add 5 Revisions for this test. Their corresponding text id's
- // are stored in the following 5 variables.
- private $textId1;
- private $textId2;
- private $textId3;
- private $textId4;
- private $textId5;
-
-
- /**
- * @var Exception|null As the current MediaWikiTestCase::run is not
- * robust enough to recover from thrown exceptions directly, we cannot
- * throw frow within addDBData, although it would be appropriate. Hence,
- * we catch the exception and store it until we are in setUp and may
- * finally rethrow the exception without crashing the test suite.
- */
- private $exceptionFromAddDBData;
-
- /**
- * @var FetchText the (mocked) FetchText that is to test
- */
- private $fetchText;
-
- /**
- * Adds a revision to a page, while returning the resuting text's id
- *
- * @param $page WikiPage The page to add the revision to
- * @param $text String The revisions text
- * @param $text String The revisions summare
- *
- * @throws MWExcepion
- */
- private function addRevision( $page, $text, $summary ) {
- $status = $page->doEdit( $text, $summary );
- if ( $status->isGood() ) {
- $value = $status->getValue();
- $revision = $value['revision'];
- $id = $revision->getTextId();
- if ( $id > 0 ) {
- return $id;
- }
- }
- throw new MWException( "Could not determine text id" );
- }
-
-
- function addDBData() {
- $this->tablesUsed[] = 'page';
- $this->tablesUsed[] = 'revision';
- $this->tablesUsed[] = 'text';
-
- try {
- $title = Title::newFromText( 'FetchTextTestPage1' );
- $page = WikiPage::factory( $title );
- $this->textId1 = $this->addRevision( $page, "FetchTextTestPage1Text1", "FetchTextTestPage1Summary1" );
-
- $title = Title::newFromText( 'FetchTextTestPage2' );
- $page = WikiPage::factory( $title );
- $this->textId2 = $this->addRevision( $page, "FetchTextTestPage2Text1", "FetchTextTestPage2Summary1" );
- $this->textId3 = $this->addRevision( $page, "FetchTextTestPage2Text2", "FetchTextTestPage2Summary2" );
- $this->textId4 = $this->addRevision( $page, "FetchTextTestPage2Text3", "FetchTextTestPage2Summary3" );
- $this->textId5 = $this->addRevision( $page, "FetchTextTestPage2Text4 some additional Text ", "FetchTextTestPage2Summary4 extra " );
- } catch ( Exception $e ) {
- // We'd love to pass $e directly. However, ... see
- // documentation of exceptionFromAddDBData
- $this->exceptionFromAddDBData = $e;
- }
- }
-
-
- protected function setUp() {
- parent::setUp();
-
- // Check if any Exception is stored for rethrowing from addDBData
- if ( $this->exceptionFromAddDBData !== null ) {
- throw $this->exceptionFromAddDBData;
- }
-
- $this->fetchText = new SemiMockedFetchText();
- }
-
-
- /**
- * Helper to relate FetchText's input and output
- */
- private function assertFilter( $input, $expectedOutput ) {
- $this->fetchText->mockStdin( $input );
- $this->fetchText->execute();
- $invocations = $this->fetchText->mockGetInvocations();
- $this->assertEquals( 1, $invocations['getStdin'],
- "getStdin invocation counter" );
- $this->expectOutputString( $expectedOutput );
- }
-
-
-
- // Instead of the following functions, a data provider would be great.
- // However, as data providers are evaluated /before/ addDBData, a data
- // provider would not know the required ids.
-
- function testExistingSimple() {
- $this->assertFilter( $this->textId2,
- $this->textId2 . "\n23\nFetchTextTestPage2Text1" );
- }
-
- function testExistingSimpleWithNewline() {
- $this->assertFilter( $this->textId2 . "\n",
- $this->textId2 . "\n23\nFetchTextTestPage2Text1" );
- }
-
- function testExistingSeveral() {
- $this->assertFilter( "$this->textId1\n$this->textId5\n"
- . "$this->textId3\n$this->textId3",
- implode( "", array(
- $this->textId1 . "\n23\nFetchTextTestPage1Text1",
- $this->textId5 . "\n44\nFetchTextTestPage2Text4 "
- . "some additional Text",
- $this->textId3 . "\n23\nFetchTextTestPage2Text2",
- $this->textId3 . "\n23\nFetchTextTestPage2Text2"
- ) ) );
- }
-
- function testEmpty() {
- $this->assertFilter( "", null );
- }
-
- function testNonExisting() {
- $this->assertFilter( $this->textId5 + 10, ( $this->textId5 + 10 ) . "\n-1\n" );
- }
-
- function testNegativeInteger() {
- $this->assertFilter( "-42", "-42\n-1\n" );
- }
-
- function testFloatingPointNumberExisting() {
- // float -> int -> revision
- $this->assertFilter( $this->textId3 + 0.14159,
- $this->textId3 . "\n23\nFetchTextTestPage2Text2" );
- }
-
- function testFloatingPointNumberNonExisting() {
- $this->assertFilter( $this->textId5 + 3.14159,
- ( $this->textId5 + 3 ) . "\n-1\n" );
- }
-
- function testCharacters() {
- $this->assertFilter( "abc", "0\n-1\n" );
- }
-
- function testMix() {
- $this->assertFilter( "ab\n" . $this->textId4 . ".5cd\n\nefg\n" . $this->textId2
- . "\n" . $this->textId3,
- implode( "", array(
- "0\n-1\n",
- $this->textId4 . "\n23\nFetchTextTestPage2Text3",
- "0\n-1\n",
- "0\n-1\n",
- $this->textId2 . "\n23\nFetchTextTestPage2Text1",
- $this->textId3 . "\n23\nFetchTextTestPage2Text2"
- ) ) );
- }
-
-}
diff --git a/tests/phpunit/maintenance/getSlaveServerTest.php b/tests/phpunit/maintenance/getSlaveServerTest.php
deleted file mode 100644
index 0b7c758c..00000000
--- a/tests/phpunit/maintenance/getSlaveServerTest.php
+++ /dev/null
@@ -1,69 +0,0 @@
-db->getType() === 'sqlite' ) {
- // for SQLite, only the empty string is a good server name
- return '';
- }
-
- $octet = '([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])';
- $ip = "(($octet\.){3}$octet)";
-
- $label = '([a-zA-Z]([a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)';
- $hostname = "($label(\.$label)*)";
-
- return "($ip|$hostname)(:[0-9]{1,5})?";
- }
-
- function testPlain() {
- $gss = new GetSlaveServer();
- $gss->execute();
-
- $this->expectOutputRegex( "/^" . self::getServerRE() . "\n$/D" );
- }
-
- function testXmlDumpsBackupUseCase() {
- global $wgDBprefix;
-
- global $argv;
- $argv = array( null, "--globals" );
-
- $gss = new GetSlaveServer();
- $gss->loadParamsAndArgs();
- $gss->execute();
- $gss->globals();
-
- // The main answer
- $output = $this->getActualOutput();
- $firstLineEndPos = strpos( $output,"\n");
- if ( $firstLineEndPos === FALSE ) {
- $this->fail( "Could not find end of first line of output" );
- }
- $firstLine = substr( $output, 0 , $firstLineEndPos );
- $this->assertRegExp( "/^" . self::getServerRE() . "$/D",
- $firstLine, "DB Server" );
-
- // xmldumps-backup relies on the wgDBprefix in the output.
- $this->expectOutputRegex( "/^[[:space:]]*\[wgDBprefix\][[:space:]]*=> "
- . $wgDBprefix . "$/m" );
- }
-
-
-}
diff --git a/tests/phpunit/phpunit.php b/tests/phpunit/phpunit.php
deleted file mode 100644
index bcbf4ec1..00000000
--- a/tests/phpunit/phpunit.php
+++ /dev/null
@@ -1,107 +0,0 @@
-#!/usr/bin/env php
-addOption( 'with-phpunitdir'
- , 'Directory to include PHPUnit from, for example when using a git fetchout from upstream. Path will be prepended to PHP `include_path`.'
- , false # not required
- , true # need arg
- );
- }
-
- public function finalSetup() {
- parent::finalSetup();
-
- global $wgMainCacheType, $wgMessageCacheType, $wgParserCacheType;
- global $wgLanguageConverterCacheType, $wgUseDatabaseMessages;
- global $wgLocaltimezone, $wgLocalisationCacheConf;
- global $wgDevelopmentWarnings;
-
- // wfWarn should cause tests to fail
- $wgDevelopmentWarnings = true;
-
- $wgMainCacheType = CACHE_NONE;
- $wgMessageCacheType = CACHE_NONE;
- $wgParserCacheType = CACHE_NONE;
- $wgLanguageConverterCacheType = CACHE_NONE;
-
- $wgUseDatabaseMessages = false; # Set for future resets
-
- // Assume UTC for testing purposes
- $wgLocaltimezone = 'UTC';
-
- $wgLocalisationCacheConf['storeClass'] = 'LCStore_Null';
- }
-
- public function execute() {
- global $IP;
-
- # Make sure we have --configuration or PHPUnit might complain
- if( !in_array( '--configuration', $_SERVER['argv'] ) ) {
- //Hack to eliminate the need to use the Makefile (which sucks ATM)
- array_splice( $_SERVER['argv'], 1, 0,
- array( '--configuration', $IP . '/tests/phpunit/suite.xml' ) );
- }
-
- # --with-phpunitdir let us override the default PHPUnit version
- if( $phpunitDir = $this->getOption( 'with-phpunitdir' ) ) {
- # Sanity checks
- if( !is_dir($phpunitDir) ) {
- $this->error( "--with-phpunitdir should be set to an existing directory", 1 );
- }
- if( !is_readable( $phpunitDir."/PHPUnit/Runner/Version.php" ) ) {
- $this->error( "No usable PHPUnit installation in $phpunitDir.\nAborting.\n", 1 );
- }
-
- # Now prepends provided PHPUnit directory
- $this->output( "Will attempt loading PHPUnit from `$phpunitDir`\n" );
- set_include_path( $phpunitDir
- . PATH_SEPARATOR . get_include_path() );
-
- # Cleanup $args array so the option and its value do not
- # pollute PHPUnit
- $key = array_search( '--with-phpunitdir', $_SERVER['argv'] );
- unset( $_SERVER['argv'][$key] ); // the option
- unset( $_SERVER['argv'][$key+1] ); // its value
- $_SERVER['argv'] = array_values( $_SERVER['argv'] );
-
- }
- }
-
- public function getDbType() {
- return Maintenance::DB_ADMIN;
- }
-}
-
-$maintClass = 'PHPUnitMaintClass';
-require( RUN_MAINTENANCE_IF_MAIN );
-
-require_once( 'PHPUnit/Runner/Version.php' );
-
-if( PHPUnit_Runner_Version::id() !== '@package_version@'
- && version_compare( PHPUnit_Runner_Version::id(), '3.6.7', '<' ) ) {
- die( 'PHPUnit 3.6.7 or later required, you have ' . PHPUnit_Runner_Version::id() . ".\n" );
-}
-require_once( 'PHPUnit/Autoload.php' );
-
-require_once( "$IP/tests/TestsAutoLoader.php" );
-MediaWikiPHPUnitCommand::main();
diff --git a/tests/phpunit/run-tests.bat b/tests/phpunit/run-tests.bat
deleted file mode 100644
index e6eb3e0c..00000000
--- a/tests/phpunit/run-tests.bat
+++ /dev/null
@@ -1 +0,0 @@
-php phpunit.php --configuration suite.xml %*
diff --git a/tests/phpunit/skins/SideBarTest.php b/tests/phpunit/skins/SideBarTest.php
deleted file mode 100644
index 912d7602..00000000
--- a/tests/phpunit/skins/SideBarTest.php
+++ /dev/null
@@ -1,209 +0,0 @@
-messages array */
- private function initMessagesHref() {
- # List of default messages for the sidebar:
- $URL_messages = array(
- 'mainpage',
- 'portal-url',
- 'currentevents-url',
- 'recentchanges-url',
- 'randompage-url',
- 'helppage',
- );
-
- foreach( $URL_messages as $m ) {
- $titleName = MessageCache::singleton()->get($m);
- $title = Title::newFromText( $titleName );
- $this->messages[$m]['href'] = $title->getLocalURL();
- }
- }
-
- function setUp() {
- parent::setUp();
- $this->initMessagesHref();
- $this->skin = new SkinTemplate();
- $this->skin->getContext()->setLanguage( Language::factory( 'en' ) );
- }
- function tearDown() {
- parent::tearDown();
- $this->skin = null;
- }
-
- /**
- * Internal helper to test the sidebar
- * @param $expected
- * @param $text
- * @param $message (Default: '')
- */
- private function assertSideBar( $expected, $text, $message = '' ) {
- $bar = array();
- $this->skin->addToSidebarPlain( $bar, $text );
- $this->assertEquals( $expected, $bar, $message );
- }
-
- function testSidebarWithOnlyTwoTitles() {
- $this->assertSideBar(
- array(
- 'Title1' => array(),
- 'Title2' => array(),
- ),
-'* Title1
-* Title2
-'
- );
- }
-
- function testExpandMessages() {
- $this->assertSidebar(
- array( 'Title' => array(
- array(
- 'text' => 'Help',
- 'href' => $this->messages['helppage']['href'],
- 'id' => 'n-help',
- 'active' => null
- )
- )),
-'* Title
-** helppage|help
-'
- );
- }
-
- function testExternalUrlsRequireADescription() {
- $this->assertSidebar(
- array( 'Title' => array(
- # ** http://www.mediawiki.org/| Home
- array(
- 'text' => 'Home',
- 'href' => 'http://www.mediawiki.org/',
- 'id' => 'n-Home',
- 'active' => null,
- 'rel' => 'nofollow',
- ),
- # ** http://valid.no.desc.org/
- # ... skipped since it is missing a pipe with a description
- )),
-'* Title
-** http://www.mediawiki.org/| Home
-** http://valid.no.desc.org/
-'
-
- );
-
- }
- /**
- * bug 33321 - Make sure there's a | after transforming.
- * @group Database
- */
- function testTrickyPipe() {
- $this->assertSidebar(
- array( 'Title' => array(
- # The first 2 are skipped
- # Doesn't really test the url properly
- # because it will vary with $wgArticlePath et al.
- # ** Baz|Fred
- array(
- 'text' => 'Fred',
- 'href' => Title::newFromText( 'Baz' )->getLocalUrl(),
- 'id' => 'n-Fred',
- 'active' => null,
- ),
- array(
- 'text' => 'title-to-display',
- 'href' => Title::newFromText( 'page-to-go-to' )->getLocalUrl(),
- 'id' => 'n-title-to-display',
- 'active' => null,
- ),
- )),
-'* Title
-** {{PAGENAME|Foo}}
-** Bar
-** Baz|Fred
-** {{PLURAL:1|page-to-go-to{{int:pipe-separator/en}}title-to-display|branch not taken}}
-'
- );
-
- }
-
-
- #### Attributes for external links ##########################
- private function getAttribs( ) {
- # Sidebar text we will use everytime
- $text = '* Title
-** http://www.mediawiki.org/| Home';
-
- $bar = array();
- $this->skin->addToSideBarPlain( $bar, $text );
-
- return $bar['Title'][0];
- }
-
- /**
- * Simple test to verify our helper assertAttribs() is functional
- * Please note this assume MediaWiki default settings:
- * $wgNoFollowLinks = true
- * $wgExternalLinkTarget = false
- */
- function testTestAttributesAssertionHelper() {
- $attribs = $this->getAttribs();
-
- $this->assertArrayHasKey( 'rel', $attribs );
- $this->assertEquals( 'nofollow', $attribs['rel'] );
-
- $this->assertArrayNotHasKey( 'target', $attribs );
- }
-
- /**
- * Test $wgNoFollowLinks in sidebar
- */
- function testRespectWgnofollowlinks() {
- global $wgNoFollowLinks;
- $saved = $wgNoFollowLinks;
- $wgNoFollowLinks = false;
-
- $attribs = $this->getAttribs();
- $this->assertArrayNotHasKey( 'rel', $attribs,
- 'External URL in sidebar do not have rel=nofollow when $wgNoFollowLinks = false'
- );
-
- // Restore global
- $wgNoFollowLinks = $saved;
- }
-
- /**
- * Test $wgExternaLinkTarget in sidebar
- */
- function testRespectExternallinktarget() {
- global $wgExternalLinkTarget;
- $saved = $wgExternalLinkTarget;
-
- $wgExternalLinkTarget = '_blank';
- $attribs = $this->getAttribs();
- $this->assertArrayHasKey( 'target', $attribs );
- $this->assertEquals( $attribs['target'], '_blank' );
-
- $wgExternalLinkTarget = '_self';
- $attribs = $this->getAttribs();
- $this->assertArrayHasKey( 'target', $attribs );
- $this->assertEquals( $attribs['target'], '_self' );
-
- // Restore global
- $wgExternalLinkTarget = $saved;
- }
-
-}
diff --git a/tests/phpunit/suite.xml b/tests/phpunit/suite.xml
deleted file mode 100644
index 56f64477..00000000
--- a/tests/phpunit/suite.xml
+++ /dev/null
@@ -1,49 +0,0 @@
-
-
-
-
-
-
- includes
-
-
- languages
-
-
- skins
-
-
-
- maintenance
-
-
- StructureTest.php
-
-
- suites/UploadFromUrlTestSuite.php
-
-
- suites/ExtensionsTestSuite.php
-
-
-
-
- Utility
- Broken
- ParserFuzz
- Stub
-
-
-
diff --git a/tests/phpunit/suites/ExtensionsTestSuite.php b/tests/phpunit/suites/ExtensionsTestSuite.php
deleted file mode 100644
index d728807f..00000000
--- a/tests/phpunit/suites/ExtensionsTestSuite.php
+++ /dev/null
@@ -1,33 +0,0 @@
-addTestFile( $file );
- }
- if ( !count( $files ) ) {
- $this->addTest( new DummyExtensionsTest( 'testNothing' ) );
- }
- }
-
- public static function suite() {
- return new self;
- }
-}
-
-/**
- * Needed to avoid warnings like 'No tests found in class "ExtensionsTestSuite".'
- * when no extensions with tests are used.
- */
-class DummyExtensionsTest extends MediaWikiTestCase {
- public function testNothing() {
- $this->assertTrue( true );
- }
-}
diff --git a/tests/phpunit/suites/UploadFromUrlTestSuite.php b/tests/phpunit/suites/UploadFromUrlTestSuite.php
deleted file mode 100644
index f2638111..00000000
--- a/tests/phpunit/suites/UploadFromUrlTestSuite.php
+++ /dev/null
@@ -1,204 +0,0 @@
- 'LocalRepo',
- 'name' => 'local',
- 'url' => 'http://example.com/images',
- 'hashLevels' => 2,
- 'transformVia404' => false,
- 'backend' => new FSFileBackend( array(
- 'name' => 'local-backend',
- 'lockManager' => 'fsLockManager',
- 'containerPaths' => array(
- 'local-public' => wfTempDir() . '/test-repo/public',
- 'local-thumb' => wfTempDir() . '/test-repo/thumb',
- 'local-temp' => wfTempDir() . '/test-repo/temp',
- 'local-deleted' => wfTempDir() . '/test-repo/delete',
- )
- ) ),
- );
- foreach ( $tmpGlobals as $var => $val ) {
- if ( array_key_exists( $var, $GLOBALS ) ) {
- $this->savedGlobals[$var] = $GLOBALS[$var];
- }
- $GLOBALS[$var] = $val;
- }
-
- $wgNamespaceProtection[NS_MEDIAWIKI] = 'editinterface';
- $wgNamespaceAliases['Image'] = NS_FILE;
- $wgNamespaceAliases['Image_talk'] = NS_FILE_TALK;
-
-
- $wgEnableParserCache = false;
- DeferredUpdates::clearPendingUpdates();
- $wgMemc = wfGetMainCache();
- $messageMemc = wfGetMessageCacheStorage();
- $parserMemc = wfGetParserCacheStorage();
-
- // $wgContLang = new StubContLang;
- $wgUser = new User;
- $context = new RequestContext;
- $wgLang = $context->getLanguage();
- $wgOut = $context->getOutput();
- $wgParser = new StubObject( 'wgParser', $wgParserConf['class'], array( $wgParserConf ) );
- $wgRequest = $context->getRequest();
-
- if ( $wgStyleDirectory === false ) {
- $wgStyleDirectory = "$IP/skins";
- }
-
- RepoGroup::destroySingleton();
- FileBackendGroup::destroySingleton();
- }
-
- public function tearDown() {
- foreach ( $this->savedGlobals as $var => $val ) {
- $GLOBALS[$var] = $val;
- }
- // Restore backends
- RepoGroup::destroySingleton();
- FileBackendGroup::destroySingleton();
-
- $this->teardownUploadDir( $this->uploadDir );
- }
-
- private $uploadDir;
- private $keepUploads;
-
- /**
- * Remove the dummy uploads directory
- */
- private function teardownUploadDir( $dir ) {
- if ( $this->keepUploads ) {
- return;
- }
-
- // delete the files first, then the dirs.
- self::deleteFiles(
- array (
- "$dir/3/3a/Foobar.jpg",
- "$dir/thumb/3/3a/Foobar.jpg/180px-Foobar.jpg",
- "$dir/thumb/3/3a/Foobar.jpg/200px-Foobar.jpg",
- "$dir/thumb/3/3a/Foobar.jpg/640px-Foobar.jpg",
- "$dir/thumb/3/3a/Foobar.jpg/120px-Foobar.jpg",
-
- "$dir/0/09/Bad.jpg",
- )
- );
-
- self::deleteDirs(
- array (
- "$dir/3/3a",
- "$dir/3",
- "$dir/thumb/6/65",
- "$dir/thumb/6",
- "$dir/thumb/3/3a/Foobar.jpg",
- "$dir/thumb/3/3a",
- "$dir/thumb/3",
-
- "$dir/0/09/",
- "$dir/0/",
-
- "$dir/thumb",
- "$dir",
- )
- );
- }
-
- /**
- * Delete the specified files, if they exist.
- *
- * @param $files Array: full paths to files to delete.
- */
- private static function deleteFiles( $files ) {
- foreach ( $files as $file ) {
- if ( file_exists( $file ) ) {
- unlink( $file );
- }
- }
- }
-
- /**
- * Delete the specified directories, if they exist. Must be empty.
- *
- * @param $dirs Array: full paths to directories to delete.
- */
- private static function deleteDirs( $dirs ) {
- foreach ( $dirs as $dir ) {
- if ( is_dir( $dir ) ) {
- rmdir( $dir );
- }
- }
- }
-
- /**
- * Create a dummy uploads directory which will contain a couple
- * of files in order to pass existence tests.
- *
- * @return String: the directory
- */
- private function setupUploadDir() {
- global $IP;
-
- if ( $this->keepUploads ) {
- $dir = wfTempDir() . '/mwParser-images';
-
- if ( is_dir( $dir ) ) {
- return $dir;
- }
- } else {
- $dir = wfTempDir() . "/mwParser-" . mt_rand() . "-images";
- }
-
- wfDebug( "Creating upload directory $dir\n" );
-
- if ( file_exists( $dir ) ) {
- wfDebug( "Already exists!\n" );
- return $dir;
- }
-
- wfMkdirParents( $dir . '/3/3a', null, __METHOD__ );
- copy( "$IP/skins/monobook/headbg.jpg", "$dir/3/3a/Foobar.jpg" );
-
- wfMkdirParents( $dir . '/0/09', null, __METHOD__ );
- copy( "$IP/skins/monobook/headbg.jpg", "$dir/0/09/Bad.jpg" );
-
- return $dir;
- }
-
- public static function suite() {
- // Hack to invoke the autoloader required to get phpunit to recognize
- // the UploadFromUrlTest class
- class_exists( 'UploadFromUrlTest' );
- $suite = new UploadFromUrlTestSuite( 'UploadFromUrlTest' );
- return $suite;
- }
-}
--
cgit v1.2.3-54-g00ecf
From 91e194556c52d2f354344f930419eef2dd6267f0 Mon Sep 17 00:00:00 2001
From: Pierre Schmitz
Date: Wed, 4 Sep 2013 05:51:59 +0200
Subject: Update to MediaWiki 1.21.2
---
.gitreview | 6 +
.jshintignore | 27 +
.jshintrc | 34 +
RELEASE-NOTES-1.21 | 16 +-
extensions/Cite/.gitreview | 5 +
extensions/ConfirmEdit/.gitreview | 5 +
extensions/ConfirmEdit/ReCaptcha.i18n.php | 3 +-
extensions/Gadgets/.gitreview | 5 +
extensions/Gadgets/tests/GadgetTest.php | 81 +
extensions/ImageMap/.gitreview | 5 +
extensions/InputBox/.gitreview | 5 +
extensions/Interwiki/.gitreview | 6 +
extensions/LocalisationUpdate/.gitreview | 5 +
extensions/LocalisationUpdate/tests/tokenTest.php | 91 +
extensions/Nuke/.gitreview | 5 +
extensions/ParserFunctions/.gitreview | 5 +
.../ParserFunctions/ParserFunctions.i18n.magic.php | 4 +-
.../ParserFunctions/tests/ExpressionTest.php | 76 +
extensions/PdfHandler/.gitreview | 5 +
extensions/PdfHandler/PdfHandler_body.php | 2 +-
extensions/Poem/.gitreview | 5 +
extensions/Renameuser/.gitreview | 5 +
extensions/SpamBlacklist/.gitreview | 5 +
extensions/SyntaxHighlight_GeSHi/.gitreview | 5 +
.../geshi/contrib/aliased.php | 123 -
.../SyntaxHighlight_GeSHi/geshi/contrib/cssgen.php | 466 -
.../geshi/contrib/cssgen2.php | 59 -
.../geshi/contrib/example.php | 217 -
.../geshi/contrib/langcheck.php | 769 -
.../geshi/contrib/langwiz.php | 1158 --
extensions/TitleBlacklist/.gitreview | 5 +
.../tests/ApiQueryTitleBlacklistTest.php | 110 +
extensions/TitleBlacklist/tests/testSource | 4 +
extensions/Vector/.gitreview | 5 +
extensions/WikiEditor/.gitreview | 6 +
extensions/WikiEditor/.jshintignore | 2 +
extensions/WikiEditor/.jshintrc | 9 +
.../tests/selenium/WikiDialogs_Links.php | 67 +
.../tests/selenium/WikiDialogs_Links_Setup.php | 295 +
.../tests/selenium/WikiEditorConstants.php | 84 +
.../tests/selenium/WikiEditorSeleniumConfig.php | 27 +
.../tests/selenium/WikiEditorTestSuite.php | 35 +
includes/DefaultSettings.php | 2 +-
includes/api/ApiBlock.php | 15 -
includes/api/ApiCreateAccount.php | 4 +
includes/api/ApiLogin.php | 9 +
includes/api/ApiMain.php | 10 +-
includes/api/ApiQueryDeletedrevs.php | 5 +
includes/api/ApiTokens.php | 5 +
includes/api/ApiUnblock.php | 15 -
includes/filerepo/file/LocalFile.php | 16 +
includes/installer/Installer.php | 29 +-
includes/installer/MysqlUpdater.php | 2 +-
includes/installer/WebInstallerPage.php | 2 +-
includes/libs/IEUrlExtension.php | 2 +-
includes/resourceloader/ResourceLoader.php | 26 +-
includes/revisiondelete/RevisionDelete.php | 11 +
includes/zhtable/trad2simp_supp_unset.manual | 0
.../language/zhtable/trad2simp_supp_unset.manual | 0
.../postgres/archives/patch-ipb_address_unique.sql | 0
skins/common/images/icons/fileicon-djvu.xcf | Bin 0 -> 83394 bytes
skins/common/images/icons/fileicon-ogg.xcf | Bin 0 -> 40236 bytes
tests/.htaccess | 1 +
tests/RunSeleniumTests.php | 258 +
tests/TestsAutoLoader.php | 104 +
tests/parser/README | 8 +
tests/parser/extraParserTests.txt | Bin 0 -> 1261 bytes
tests/parser/parserTest.inc | 1349 ++
tests/parser/parserTests.txt | 13859 +++++++++++++++++++
tests/parser/parserTestsParserHook.php | 66 +
.../parser/preprocess/All_system_messages.expected | 5646 ++++++++
tests/parser/preprocess/All_system_messages.txt | 5645 ++++++++
tests/parser/preprocess/Factorial.expected | 17 +
tests/parser/preprocess/Factorial.txt | 16 +
tests/parser/preprocess/Fundraising.expected | 18 +
tests/parser/preprocess/Fundraising.txt | 17 +
tests/parser/preprocess/NestedTemplates.expected | 90 +
tests/parser/preprocess/NestedTemplates.txt | 89 +
tests/parser/preprocess/QuoteQuran.expected | 140 +
tests/parser/preprocess/QuoteQuran.txt | 139 +
tests/parserTests.php | 94 +
tests/phpunit/AutoLoaderTest.php | 51 +
tests/phpunit/Makefile | 91 +
tests/phpunit/MediaWikiLangTestCase.php | 29 +
tests/phpunit/MediaWikiPHPUnitCommand.php | 101 +
tests/phpunit/MediaWikiTestCase.php | 938 ++
tests/phpunit/README | 53 +
tests/phpunit/StructureTest.php | 63 +
tests/phpunit/TODO | 10 +
tests/phpunit/bootstrap.php | 32 +
tests/phpunit/data/db/mysql/functions.sql | 12 +
tests/phpunit/data/db/postgres/functions.sql | 12 +
tests/phpunit/data/db/sqlite/tables-1.13.sql | 342 +
tests/phpunit/data/db/sqlite/tables-1.15.sql | 454 +
tests/phpunit/data/db/sqlite/tables-1.16.sql | 483 +
tests/phpunit/data/db/sqlite/tables-1.17.sql | 516 +
tests/phpunit/data/db/sqlite/tables-1.18.sql | 535 +
tests/phpunit/data/media/1bit-png.png | Bin 0 -> 167 bytes
tests/phpunit/data/media/80x60-2layers.xcf | Bin 0 -> 1162 bytes
tests/phpunit/data/media/80x60-Greyscale.xcf | Bin 0 -> 667 bytes
tests/phpunit/data/media/80x60-RGB.xcf | Bin 0 -> 677 bytes
.../Animated_PNG_example_bouncing_beach_ball.png | Bin 0 -> 72209 bytes
tests/phpunit/data/media/Gtk-media-play-ltr.svg | 35 +
tests/phpunit/data/media/Png-native-test.png | Bin 0 -> 4665 bytes
tests/phpunit/data/media/QA_icon.svg | 77 +
tests/phpunit/data/media/README | 38 +
tests/phpunit/data/media/Toll_Texas_1.svg | 150 +
.../media/US_states_by_total_state_tax_revenue.svg | 248 +
tests/phpunit/data/media/Wikimedia-logo.svg | 14 +
.../data/media/Xmp-exif-multilingual_test.jpg | Bin 0 -> 12544 bytes
tests/phpunit/data/media/animated-xmp.gif | Bin 0 -> 3864 bytes
tests/phpunit/data/media/animated.gif | Bin 0 -> 497 bytes
tests/phpunit/data/media/broken_exif_date.jpg | Bin 0 -> 3233 bytes
tests/phpunit/data/media/exif-gps.jpg | Bin 0 -> 665 bytes
tests/phpunit/data/media/exif-user-comment.jpg | Bin 0 -> 484 bytes
tests/phpunit/data/media/greyscale-na-png.png | Bin 0 -> 365 bytes
tests/phpunit/data/media/greyscale-png.png | Bin 0 -> 415 bytes
tests/phpunit/data/media/iptc-invalid-psir.jpg | Bin 0 -> 9574 bytes
tests/phpunit/data/media/iptc-timetest-invalid.jpg | Bin 0 -> 9573 bytes
tests/phpunit/data/media/iptc-timetest.jpg | Bin 0 -> 9573 bytes
tests/phpunit/data/media/jpeg-comment-binary.jpg | Bin 0 -> 448 bytes
.../phpunit/data/media/jpeg-comment-iso8859-1.jpg | Bin 0 -> 447 bytes
tests/phpunit/data/media/jpeg-comment-multiple.jpg | Bin 0 -> 431 bytes
tests/phpunit/data/media/jpeg-comment-utf.jpg | Bin 0 -> 445 bytes
tests/phpunit/data/media/jpeg-iptc-bad-hash.jpg | Bin 0 -> 499 bytes
tests/phpunit/data/media/jpeg-iptc-good-hash.jpg | Bin 0 -> 499 bytes
tests/phpunit/data/media/jpeg-padding-even.jpg | Bin 0 -> 450 bytes
tests/phpunit/data/media/jpeg-padding-odd.jpg | Bin 0 -> 451 bytes
tests/phpunit/data/media/jpeg-xmp-alt.jpg | Bin 0 -> 3255 bytes
tests/phpunit/data/media/jpeg-xmp-psir.jpg | Bin 0 -> 3308 bytes
tests/phpunit/data/media/jpeg-xmp-psir.xmp | 35 +
tests/phpunit/data/media/landscape-plain.jpg | Bin 0 -> 38771 bytes
tests/phpunit/data/media/nonanimated.gif | Bin 0 -> 200 bytes
tests/phpunit/data/media/portrait-rotated.jpg | Bin 0 -> 38577 bytes
tests/phpunit/data/media/rgb-na-png.png | Bin 0 -> 593 bytes
tests/phpunit/data/media/rgb-png.png | Bin 0 -> 663 bytes
tests/phpunit/data/media/test.jpg | Bin 0 -> 437 bytes
tests/phpunit/data/media/test.tiff | Bin 0 -> 566 bytes
tests/phpunit/data/media/xmp.png | Bin 0 -> 582 bytes
tests/phpunit/data/xmp/1.result.php | 8 +
tests/phpunit/data/xmp/1.xmp | 11 +
tests/phpunit/data/xmp/2.result.php | 8 +
tests/phpunit/data/xmp/2.xmp | 12 +
tests/phpunit/data/xmp/3-invalid.result.php | 7 +
tests/phpunit/data/xmp/3-invalid.xmp | 31 +
tests/phpunit/data/xmp/3.result.php | 8 +
tests/phpunit/data/xmp/3.xmp | 29 +
tests/phpunit/data/xmp/4.result.php | 7 +
tests/phpunit/data/xmp/4.xmp | 22 +
tests/phpunit/data/xmp/5.result.php | 7 +
tests/phpunit/data/xmp/5.xmp | 16 +
tests/phpunit/data/xmp/6.result.php | 8 +
tests/phpunit/data/xmp/6.xmp | 18 +
tests/phpunit/data/xmp/7.result.php | 52 +
tests/phpunit/data/xmp/7.xmp | 67 +
tests/phpunit/data/xmp/README | 3 +
tests/phpunit/data/xmp/bag-for-seq.result.php | 10 +
tests/phpunit/data/xmp/bag-for-seq.xmp | 1 +
tests/phpunit/data/xmp/flash.result.php | 8 +
tests/phpunit/data/xmp/flash.xmp | 11 +
tests/phpunit/data/xmp/gps.result.php | 11 +
tests/phpunit/data/xmp/gps.xmp | 17 +
.../data/xmp/invalid-child-not-struct.result.php | 7 +
.../phpunit/data/xmp/invalid-child-not-struct.xmp | 12 +
tests/phpunit/data/xmp/no-namespace.result.php | 7 +
tests/phpunit/data/xmp/no-namespace.xmp | 11 +
.../data/xmp/no-recognized-props.result.php | 2 +
tests/phpunit/data/xmp/no-recognized-props.xmp | 8 +
tests/phpunit/data/xmp/utf16BE.result.php | 12 +
tests/phpunit/data/xmp/utf16BE.xmp | Bin 0 -> 930 bytes
tests/phpunit/data/xmp/utf16LE.result.php | 12 +
tests/phpunit/data/xmp/utf16LE.xmp | Bin 0 -> 930 bytes
tests/phpunit/data/xmp/utf32BE.result.php | 12 +
tests/phpunit/data/xmp/utf32BE.xmp | Bin 0 -> 1856 bytes
tests/phpunit/data/xmp/utf32LE.result.php | 12 +
tests/phpunit/data/xmp/utf32LE.xmp | Bin 0 -> 1856 bytes
tests/phpunit/data/xmp/xmpExt.result.php | 8 +
tests/phpunit/data/xmp/xmpExt.xmp | 13 +
tests/phpunit/data/xmp/xmpExt2.xmp | 8 +
tests/phpunit/data/zip/cd-gap.zip | Bin 0 -> 182 bytes
tests/phpunit/data/zip/cd-truncated.zip | Bin 0 -> 171 bytes
tests/phpunit/data/zip/class-trailing-null.zip | Bin 0 -> 173 bytes
tests/phpunit/data/zip/class-trailing-slash.zip | Bin 0 -> 173 bytes
tests/phpunit/data/zip/class.zip | Bin 0 -> 173 bytes
tests/phpunit/data/zip/empty.zip | Bin 0 -> 22 bytes
tests/phpunit/data/zip/looks-like-zip64.zip | Bin 0 -> 173 bytes
tests/phpunit/data/zip/nosig.zip | Bin 0 -> 173 bytes
tests/phpunit/data/zip/split.zip | Bin 0 -> 196 bytes
tests/phpunit/data/zip/trail.zip | Bin 0 -> 181 bytes
tests/phpunit/data/zip/wrong-cd-start-disk.zip | Bin 0 -> 173 bytes
tests/phpunit/data/zip/wrong-central-entry-sig.zip | Bin 0 -> 173 bytes
tests/phpunit/docs/ExportDemoTest.php | 39 +
tests/phpunit/includes/ArticleTablesTest.php | 33 +
tests/phpunit/includes/ArticleTest.php | 92 +
tests/phpunit/includes/BlockTest.php | 231 +
tests/phpunit/includes/CdbTest.php | 88 +
tests/phpunit/includes/CollationTest.php | 109 +
tests/phpunit/includes/DiffHistoryBlobTest.php | 41 +
tests/phpunit/includes/EditPageTest.php | 416 +
tests/phpunit/includes/ExternalStoreTest.php | 81 +
tests/phpunit/includes/ExtraParserTest.php | 158 +
tests/phpunit/includes/FauxResponseTest.php | 71 +
.../includes/FormOptionsInitializationTest.php | 85 +
tests/phpunit/includes/FormOptionsTest.php | 91 +
.../includes/GlobalFunctions/GlobalTest.php | 679 +
.../includes/GlobalFunctions/GlobalWithDBTest.php | 29 +
tests/phpunit/includes/GlobalFunctions/README | 2 +
.../includes/GlobalFunctions/wfAssembleUrlTest.php | 110 +
.../includes/GlobalFunctions/wfBCP47Test.php | 134 +
.../includes/GlobalFunctions/wfBaseConvertTest.php | 181 +
.../includes/GlobalFunctions/wfBaseNameTest.php | 36 +
.../includes/GlobalFunctions/wfExpandUrlTest.php | 113 +
.../includes/GlobalFunctions/wfGetCallerTest.php | 35 +
.../includes/GlobalFunctions/wfParseUrlTest.php | 143 +
.../GlobalFunctions/wfRemoveDotSegmentsTest.php | 89 +
.../GlobalFunctions/wfShorthandToIntegerTest.php | 28 +
.../includes/GlobalFunctions/wfTimestampTest.php | 133 +
.../includes/GlobalFunctions/wfUrlencodeTest.php | 116 +
tests/phpunit/includes/HooksTest.php | 137 +
tests/phpunit/includes/HtmlTest.php | 620 +
tests/phpunit/includes/HttpTest.php | 213 +
tests/phpunit/includes/IPTest.php | 541 +
tests/phpunit/includes/JsonTest.php | 27 +
tests/phpunit/includes/LanguageConverterTest.php | 135 +
tests/phpunit/includes/LicensesTest.php | 22 +
tests/phpunit/includes/LinkerTest.php | 71 +
tests/phpunit/includes/LinksUpdateTest.php | 164 +
tests/phpunit/includes/LocalFileTest.php | 107 +
tests/phpunit/includes/LocalisationCacheTest.php | 31 +
tests/phpunit/includes/MWFunctionTest.php | 75 +
tests/phpunit/includes/MWNamespaceTest.php | 574 +
tests/phpunit/includes/MessageTest.php | 74 +
tests/phpunit/includes/OutputPageTest.php | 172 +
tests/phpunit/includes/PathRouterTest.php | 255 +
tests/phpunit/includes/PreferencesTest.php | 82 +
tests/phpunit/includes/Providers.php | 44 +
tests/phpunit/includes/RecentChangeTest.php | 280 +
tests/phpunit/includes/RequestContextTest.php | 69 +
tests/phpunit/includes/ResourceLoaderTest.php | 91 +
tests/phpunit/includes/RevisionStorageTest.php | 546 +
.../RevisionStorageTest_ContentHandlerUseDB.php | 95 +
tests/phpunit/includes/RevisionTest.php | 445 +
tests/phpunit/includes/SampleTest.php | 105 +
tests/phpunit/includes/SanitizerTest.php | 250 +
.../includes/SanitizerValidateEmailTest.php | 96 +
.../phpunit/includes/SeleniumConfigurationTest.php | 222 +
tests/phpunit/includes/SiteConfigurationTest.php | 312 +
tests/phpunit/includes/StringUtilsTest.php | 143 +
tests/phpunit/includes/TemplateCategoriesTest.php | 37 +
tests/phpunit/includes/TestUser.php | 58 +
tests/phpunit/includes/TimeAdjustTest.php | 45 +
tests/phpunit/includes/TimestampTest.php | 86 +
tests/phpunit/includes/TitleMethodsTest.php | 290 +
tests/phpunit/includes/TitlePermissionTest.php | 662 +
tests/phpunit/includes/TitleTest.php | 329 +
tests/phpunit/includes/UIDGeneratorTest.php | 76 +
tests/phpunit/includes/UserTest.php | 217 +
tests/phpunit/includes/WebRequestTest.php | 220 +
tests/phpunit/includes/WikiPageTest.php | 1018 ++
.../includes/WikiPageTest_ContentHandlerUseDB.php | 62 +
tests/phpunit/includes/XmlJsTest.php | 9 +
tests/phpunit/includes/XmlSelectTest.php | 150 +
tests/phpunit/includes/XmlTest.php | 336 +
tests/phpunit/includes/ZipDirectoryReaderTest.php | 80 +
.../includes/api/ApiAccountCreationTest.php | 153 +
tests/phpunit/includes/api/ApiBlockTest.php | 118 +
tests/phpunit/includes/api/ApiEditPageTest.php | 352 +
tests/phpunit/includes/api/ApiOptionsTest.php | 412 +
tests/phpunit/includes/api/ApiParseTest.php | 30 +
tests/phpunit/includes/api/ApiPurgeTest.php | 41 +
tests/phpunit/includes/api/ApiTest.php | 266 +
tests/phpunit/includes/api/ApiTestCase.php | 239 +
tests/phpunit/includes/api/ApiTestCaseUpload.php | 149 +
tests/phpunit/includes/api/ApiUploadTest.php | 565 +
tests/phpunit/includes/api/ApiWatchTest.php | 177 +
.../phpunit/includes/api/PrefixUniquenessTest.php | 25 +
.../phpunit/includes/api/RandomImageGenerator.php | 465 +
.../includes/api/format/ApiFormatPhpTest.php | 19 +
.../includes/api/format/ApiFormatTestBase.php | 22 +
.../phpunit/includes/api/generateRandomImages.php | 46 +
.../includes/api/query/ApiQueryBasicTest.php | 348 +
.../includes/api/query/ApiQueryContinue2Test.php | 68 +
.../includes/api/query/ApiQueryContinueTest.php | 313 +
.../api/query/ApiQueryContinueTestBase.php | 203 +
.../includes/api/query/ApiQueryRevisionsTest.php | 39 +
tests/phpunit/includes/api/query/ApiQueryTest.php | 69 +
.../includes/api/query/ApiQueryTestBase.php | 149 +
tests/phpunit/includes/api/words.txt | 1000 ++
tests/phpunit/includes/cache/GenderCacheTest.php | 101 +
.../phpunit/includes/cache/ProcessCacheLRUTest.php | 239 +
.../includes/content/ContentHandlerTest.php | 424 +
tests/phpunit/includes/content/CssContentTest.php | 81 +
.../includes/content/JavaScriptContentTest.php | 273 +
tests/phpunit/includes/content/TextContentTest.php | 431 +
.../content/WikitextContentHandlerTest.php | 185 +
.../includes/content/WikitextContentTest.php | 386 +
tests/phpunit/includes/db/DatabaseSQLTest.php | 148 +
tests/phpunit/includes/db/DatabaseSqliteTest.php | 389 +
tests/phpunit/includes/db/DatabaseTest.php | 212 +
tests/phpunit/includes/db/ORMRowTest.php | 225 +
tests/phpunit/includes/db/ORMTableTest.php | 146 +
tests/phpunit/includes/db/TestORMRowTest.php | 199 +
tests/phpunit/includes/debug/MWDebugTest.php | 72 +
.../includes/filebackend/FileBackendTest.php | 2189 +++
tests/phpunit/includes/filerepo/FileRepoTest.php | 48 +
tests/phpunit/includes/filerepo/StoreBatchTest.php | 123 +
.../includes/installer/InstallDocFormatterTest.php | 64 +
tests/phpunit/includes/jobqueue/JobQueueTest.php | 292 +
tests/phpunit/includes/json/ServicesJsonTest.php | 93 +
tests/phpunit/includes/libs/CSSJanusTest.php | 560 +
tests/phpunit/includes/libs/CSSMinTest.php | 133 +
.../includes/libs/GenericArrayObjectTest.php | 262 +
tests/phpunit/includes/libs/IEUrlExtensionTest.php | 126 +
.../includes/libs/JavaScriptMinifierTest.php | 170 +
.../phpunit/includes/logging/LogFormatterTest.php | 207 +
tests/phpunit/includes/logging/LogTests.i18n.php | 15 +
.../includes/media/BitmapMetadataHandlerTest.php | 152 +
tests/phpunit/includes/media/BitmapScalingTest.php | 154 +
tests/phpunit/includes/media/ExifBitmapTest.php | 104 +
tests/phpunit/includes/media/ExifRotationTest.php | 261 +
tests/phpunit/includes/media/ExifTest.php | 44 +
.../phpunit/includes/media/FormatMetadataTest.php | 50 +
.../includes/media/GIFMetadataExtractorTest.php | 106 +
tests/phpunit/includes/media/GIFTest.php | 104 +
tests/phpunit/includes/media/IPTCTest.php | 60 +
.../includes/media/JpegMetadataExtractorTest.php | 106 +
tests/phpunit/includes/media/JpegTest.php | 29 +
tests/phpunit/includes/media/MediaHandlerTest.php | 48 +
.../includes/media/PNGMetadataExtractorTest.php | 153 +
tests/phpunit/includes/media/PNGTest.php | 107 +
.../includes/media/SVGMetadataExtractorTest.php | 107 +
tests/phpunit/includes/media/TiffTest.php | 31 +
tests/phpunit/includes/media/XMPTest.php | 161 +
tests/phpunit/includes/media/XMPValidateTest.php | 47 +
tests/phpunit/includes/normal/CleanUpTest.php | 405 +
.../phpunit/includes/objectcache/BagOStuffTest.php | 138 +
.../phpunit/includes/parser/MagicVariableTest.php | 219 +
.../includes/parser/MediaWikiParserTest.php | 34 +
tests/phpunit/includes/parser/NewParserTest.php | 914 ++
.../phpunit/includes/parser/ParserMethodsTest.php | 49 +
tests/phpunit/includes/parser/ParserOutputTest.php | 55 +
.../phpunit/includes/parser/ParserPreloadTest.php | 72 +
tests/phpunit/includes/parser/PreprocessorTest.php | 229 +
tests/phpunit/includes/parser/TagHooksTest.php | 82 +
tests/phpunit/includes/search/SearchEngineTest.php | 176 +
tests/phpunit/includes/search/SearchUpdateTest.php | 81 +
tests/phpunit/includes/site/MediaWikiSiteTest.php | 89 +
tests/phpunit/includes/site/SiteListTest.php | 190 +
tests/phpunit/includes/site/SiteSQLStoreTest.php | 123 +
tests/phpunit/includes/site/SiteTest.php | 267 +
tests/phpunit/includes/site/TestSites.php | 101 +
.../includes/specials/QueryAllSpecialPagesTest.php | 79 +
.../includes/specials/SpecialRecentchangesTest.php | 127 +
.../includes/specials/SpecialSearchTest.php | 140 +
.../phpunit/includes/upload/UploadFromUrlTest.php | 352 +
tests/phpunit/includes/upload/UploadStashTest.php | 77 +
tests/phpunit/includes/upload/UploadTest.php | 144 +
tests/phpunit/install-phpunit.sh | 37 +
tests/phpunit/languages/LanguageAmTest.php | 25 +
tests/phpunit/languages/LanguageArTest.php | 72 +
tests/phpunit/languages/LanguageBeTest.php | 32 +
tests/phpunit/languages/LanguageBe_taraskTest.php | 73 +
tests/phpunit/languages/LanguageBhoTest.php | 26 +
tests/phpunit/languages/LanguageBsTest.php | 33 +
.../phpunit/languages/LanguageClassesTestCase.php | 100 +
tests/phpunit/languages/LanguageCsTest.php | 32 +
tests/phpunit/languages/LanguageCuTest.php | 33 +
tests/phpunit/languages/LanguageCyTest.php | 34 +
tests/phpunit/languages/LanguageDsbTest.php | 32 +
tests/phpunit/languages/LanguageFrTest.php | 26 +
tests/phpunit/languages/LanguageGaTest.php | 26 +
tests/phpunit/languages/LanguageGdTest.php | 48 +
tests/phpunit/languages/LanguageGvTest.php | 32 +
tests/phpunit/languages/LanguageHeTest.php | 77 +
tests/phpunit/languages/LanguageHiTest.php | 26 +
tests/phpunit/languages/LanguageHrTest.php | 33 +
tests/phpunit/languages/LanguageHsbTest.php | 32 +
tests/phpunit/languages/LanguageHuTest.php | 26 +
tests/phpunit/languages/LanguageHyTest.php | 26 +
tests/phpunit/languages/LanguageKshTest.php | 26 +
tests/phpunit/languages/LanguageLnTest.php | 26 +
tests/phpunit/languages/LanguageLtTest.php | 45 +
tests/phpunit/languages/LanguageLvTest.php | 31 +
tests/phpunit/languages/LanguageMgTest.php | 27 +
tests/phpunit/languages/LanguageMkTest.php | 33 +
tests/phpunit/languages/LanguageMlTest.php | 35 +
tests/phpunit/languages/LanguageMoTest.php | 35 +
tests/phpunit/languages/LanguageMtTest.php | 64 +
tests/phpunit/languages/LanguageNlTest.php | 20 +
tests/phpunit/languages/LanguageNsoTest.php | 24 +
tests/phpunit/languages/LanguagePlTest.php | 64 +
tests/phpunit/languages/LanguageRoTest.php | 35 +
tests/phpunit/languages/LanguageRuTest.php | 78 +
tests/phpunit/languages/LanguageSeTest.php | 40 +
tests/phpunit/languages/LanguageSgsTest.php | 58 +
tests/phpunit/languages/LanguageShTest.php | 24 +
tests/phpunit/languages/LanguageSkTest.php | 32 +
tests/phpunit/languages/LanguageSlTest.php | 34 +
tests/phpunit/languages/LanguageSmaTest.php | 40 +
tests/phpunit/languages/LanguageSrTest.php | 219 +
tests/phpunit/languages/LanguageTest.php | 1352 ++
tests/phpunit/languages/LanguageTiTest.php | 24 +
tests/phpunit/languages/LanguageTlTest.php | 24 +
tests/phpunit/languages/LanguageTrTest.php | 60 +
tests/phpunit/languages/LanguageUkTest.php | 48 +
tests/phpunit/languages/LanguageUzTest.php | 115 +
tests/phpunit/languages/LanguageWaTest.php | 24 +
.../utils/CLDRPluralRuleEvaluatorTest.php | 95 +
tests/phpunit/maintenance/DumpTestCase.php | 377 +
tests/phpunit/maintenance/MaintenanceTest.php | 820 ++
tests/phpunit/maintenance/backupPrefetchTest.php | 278 +
tests/phpunit/maintenance/backupTextPassTest.php | 584 +
tests/phpunit/maintenance/backup_LogTest.php | 230 +
tests/phpunit/maintenance/backup_PageTest.php | 408 +
tests/phpunit/maintenance/fetchTextTest.php | 240 +
tests/phpunit/maintenance/getSlaveServerTest.php | 69 +
tests/phpunit/phpunit.php | 111 +
tests/phpunit/resources/ResourcesTest.php | 128 +
tests/phpunit/run-tests.bat | 1 +
tests/phpunit/skins/SideBarTest.php | 205 +
tests/phpunit/suite.xml | 50 +
tests/phpunit/suites/ExtensionsTestSuite.php | 33 +
tests/phpunit/suites/UploadFromUrlTestSuite.php | 206 +
tests/qunit/.htaccess | 1 +
tests/qunit/QUnitTestResources.php | 66 +
tests/qunit/data/callMwLoaderTestCallback.js | 1 +
tests/qunit/data/generateJqueryMsgData.php | 150 +
tests/qunit/data/load.mock.php | 58 +
tests/qunit/data/mediawiki.jqueryMsg.data.js | 492 +
tests/qunit/data/qunitOkCall.js | 2 +
tests/qunit/data/styleTest.css.php | 61 +
tests/qunit/data/testrunner.js | 408 +
.../resources/jquery/jquery.autoEllipsis.test.js | 58 +
.../resources/jquery/jquery.byteLength.test.js | 35 +
.../resources/jquery/jquery.byteLimit.test.js | 258 +
.../suites/resources/jquery/jquery.client.test.js | 375 +
.../resources/jquery/jquery.colorUtil.test.js | 63 +
.../resources/jquery/jquery.delayedBind.test.js | 37 +
.../resources/jquery/jquery.getAttrs.test.js | 13 +
.../suites/resources/jquery/jquery.hidpi.test.js | 22 +
.../resources/jquery/jquery.highlightText.test.js | 235 +
.../resources/jquery/jquery.localize.test.js | 135 +
.../resources/jquery/jquery.mwExtension.test.js | 57 +
.../resources/jquery/jquery.tabIndex.test.js | 35 +
.../resources/jquery/jquery.tablesorter.test.js | 1128 ++
.../resources/jquery/jquery.textSelection.test.js | 282 +
.../mediawiki.api/mediawiki.api.parse.test.js | 28 +
.../resources/mediawiki.api/mediawiki.api.test.js | 61 +
.../mediawiki.special.recentchanges.test.js | 63 +
.../resources/mediawiki/mediawiki.Title.test.js | 198 +
.../resources/mediawiki/mediawiki.Uri.test.js | 433 +
.../resources/mediawiki/mediawiki.cldr.test.js | 81 +
.../mediawiki/mediawiki.jqueryMsg.test.js | 599 +
.../resources/mediawiki/mediawiki.jscompat.test.js | 70 +
.../resources/mediawiki/mediawiki.language.test.js | 443 +
.../suites/resources/mediawiki/mediawiki.test.js | 765 +
.../resources/mediawiki/mediawiki.user.test.js | 53 +
.../resources/mediawiki/mediawiki.util.test.js | 303 +
tests/selenium/Selenium.php | 191 +
tests/selenium/SeleniumConfig.php | 80 +
tests/selenium/SeleniumLoader.php | 9 +
tests/selenium/SeleniumServerManager.php | 252 +
tests/selenium/SeleniumTestCase.php | 127 +
tests/selenium/SeleniumTestConsoleLogger.php | 25 +
tests/selenium/SeleniumTestConstants.php | 24 +
tests/selenium/SeleniumTestHTMLLogger.php | 36 +
tests/selenium/SeleniumTestListener.php | 65 +
tests/selenium/SeleniumTestSuite.php | 57 +
tests/selenium/data/SimpleSeleniumTestDB.sql | 1453 ++
tests/selenium/data/SimpleSeleniumTestImages.zip | Bin 0 -> 21993 bytes
tests/selenium/data/Wikipedia-logo-v2-de.png | Bin 0 -> 21479 bytes
.../data/mediawiki118_fresh_installation.sql | 1543 +++
.../MediaWikiButtonsAvailabilityTestCase.php | 90 +
.../MediaWikiDifferentDatabaseAccountTestCase.php | 73 +
.../MediaWikiDifferntDatabasePrefixTestCase.php | 88 +
...ediaWikiErrorsConnectToDatabasePageTestCase.php | 131 +
.../installer/MediaWikiErrorsNamepageTestCase.php | 119 +
.../installer/MediaWikiHelpFieldHintTestCase.php | 128 +
.../MediaWikiInstallationCommonFunction.php | 259 +
.../installer/MediaWikiInstallationConfig.php | 45 +
.../installer/MediaWikiInstallationMessage.php | 53 +
.../installer/MediaWikiInstallationVariables.php | 73 +
.../installer/MediaWikiInstallerTestSuite.php | 49 +
.../installer/MediaWikiMySQLDataBaseTestCase.php | 71 +
.../MediaWikiMySQLiteDataBaseTestCase.php | 73 +
.../MediaWikiOnAlreadyInstalledTestCase.php | 65 +
.../MediaWikiRestartInstallationTestCase.php | 104 +
.../MediaWikiRightFrameworkLinksTestCase.php | 83 +
.../MediaWikiUpgradeExistingDatabaseTestCase.php | 111 +
.../installer/MediaWikiUserInterfaceTestCase.php | 494 +
tests/selenium/installer/README.txt | 32 +
tests/selenium/selenium_settings.ini.sample | 32 +
tests/selenium/selenium_settings_grid.ini.sample | 16 +
.../suites/AddContentToNewPageTestCase.php | 173 +
tests/selenium/suites/AddNewPageTestCase.php | 59 +
tests/selenium/suites/CreateAccountTestCase.php | 109 +
tests/selenium/suites/DeletePageAdminTestCase.php | 82 +
tests/selenium/suites/EmailPasswordTestCase.php | 74 +
tests/selenium/suites/MediaWikiEditorConfig.php | 41 +
tests/selenium/suites/MediaWikiEditorTestSuite.php | 19 +
tests/selenium/suites/MediaWikiExtraTestSuite.php | 21 +
.../selenium/suites/MediawikiCoreSmokeTestCase.php | 70 +
.../suites/MediawikiCoreSmokeTestSuite.php | 19 +
tests/selenium/suites/MovePageTestCase.php | 111 +
tests/selenium/suites/MyContributionsTestCase.php | 59 +
tests/selenium/suites/MyWatchListTestCase.php | 51 +
tests/selenium/suites/PageDeleteTestSuite.php | 15 +
tests/selenium/suites/PageSearchTestCase.php | 98 +
tests/selenium/suites/PreviewPageTestCase.php | 48 +
tests/selenium/suites/SavePageTestCase.php | 53 +
tests/selenium/suites/SimpleSeleniumConfig.php | 30 +
tests/selenium/suites/SimpleSeleniumTestCase.php | 39 +
tests/selenium/suites/SimpleSeleniumTestSuite.php | 26 +
tests/selenium/suites/UserPreferencesTestCase.php | 170 +
tests/testHelpers.inc | 604 +
515 files changed, 88029 insertions(+), 2855 deletions(-)
create mode 100644 .gitreview
create mode 100644 .jshintignore
create mode 100644 .jshintrc
create mode 100644 extensions/Cite/.gitreview
create mode 100644 extensions/ConfirmEdit/.gitreview
create mode 100644 extensions/Gadgets/.gitreview
create mode 100644 extensions/Gadgets/tests/GadgetTest.php
create mode 100644 extensions/ImageMap/.gitreview
create mode 100644 extensions/InputBox/.gitreview
create mode 100644 extensions/Interwiki/.gitreview
create mode 100644 extensions/LocalisationUpdate/.gitreview
create mode 100644 extensions/LocalisationUpdate/tests/tokenTest.php
create mode 100644 extensions/Nuke/.gitreview
create mode 100644 extensions/ParserFunctions/.gitreview
create mode 100644 extensions/ParserFunctions/tests/ExpressionTest.php
create mode 100644 extensions/PdfHandler/.gitreview
create mode 100644 extensions/Poem/.gitreview
create mode 100644 extensions/Renameuser/.gitreview
create mode 100644 extensions/SpamBlacklist/.gitreview
create mode 100644 extensions/SyntaxHighlight_GeSHi/.gitreview
delete mode 100644 extensions/SyntaxHighlight_GeSHi/geshi/contrib/aliased.php
delete mode 100644 extensions/SyntaxHighlight_GeSHi/geshi/contrib/cssgen.php
delete mode 100644 extensions/SyntaxHighlight_GeSHi/geshi/contrib/cssgen2.php
delete mode 100644 extensions/SyntaxHighlight_GeSHi/geshi/contrib/example.php
delete mode 100644 extensions/SyntaxHighlight_GeSHi/geshi/contrib/langcheck.php
delete mode 100644 extensions/SyntaxHighlight_GeSHi/geshi/contrib/langwiz.php
create mode 100644 extensions/TitleBlacklist/.gitreview
create mode 100644 extensions/TitleBlacklist/tests/ApiQueryTitleBlacklistTest.php
create mode 100644 extensions/TitleBlacklist/tests/testSource
create mode 100644 extensions/Vector/.gitreview
create mode 100644 extensions/WikiEditor/.gitreview
create mode 100644 extensions/WikiEditor/.jshintignore
create mode 100644 extensions/WikiEditor/.jshintrc
create mode 100644 extensions/WikiEditor/tests/selenium/WikiDialogs_Links.php
create mode 100644 extensions/WikiEditor/tests/selenium/WikiDialogs_Links_Setup.php
create mode 100644 extensions/WikiEditor/tests/selenium/WikiEditorConstants.php
create mode 100644 extensions/WikiEditor/tests/selenium/WikiEditorSeleniumConfig.php
create mode 100644 extensions/WikiEditor/tests/selenium/WikiEditorTestSuite.php
delete mode 100644 includes/zhtable/trad2simp_supp_unset.manual
create mode 100644 maintenance/language/zhtable/trad2simp_supp_unset.manual
delete mode 100644 maintenance/postgres/archives/patch-ipb_address_unique.sql
create mode 100644 skins/common/images/icons/fileicon-djvu.xcf
create mode 100644 skins/common/images/icons/fileicon-ogg.xcf
create mode 100644 tests/.htaccess
create mode 100644 tests/RunSeleniumTests.php
create mode 100644 tests/TestsAutoLoader.php
create mode 100644 tests/parser/README
create mode 100644 tests/parser/extraParserTests.txt
create mode 100644 tests/parser/parserTest.inc
create mode 100644 tests/parser/parserTests.txt
create mode 100644 tests/parser/parserTestsParserHook.php
create mode 100644 tests/parser/preprocess/All_system_messages.expected
create mode 100644 tests/parser/preprocess/All_system_messages.txt
create mode 100644 tests/parser/preprocess/Factorial.expected
create mode 100644 tests/parser/preprocess/Factorial.txt
create mode 100644 tests/parser/preprocess/Fundraising.expected
create mode 100644 tests/parser/preprocess/Fundraising.txt
create mode 100644 tests/parser/preprocess/NestedTemplates.expected
create mode 100644 tests/parser/preprocess/NestedTemplates.txt
create mode 100644 tests/parser/preprocess/QuoteQuran.expected
create mode 100644 tests/parser/preprocess/QuoteQuran.txt
create mode 100644 tests/parserTests.php
create mode 100644 tests/phpunit/AutoLoaderTest.php
create mode 100644 tests/phpunit/Makefile
create mode 100644 tests/phpunit/MediaWikiLangTestCase.php
create mode 100644 tests/phpunit/MediaWikiPHPUnitCommand.php
create mode 100644 tests/phpunit/MediaWikiTestCase.php
create mode 100644 tests/phpunit/README
create mode 100644 tests/phpunit/StructureTest.php
create mode 100644 tests/phpunit/TODO
create mode 100644 tests/phpunit/bootstrap.php
create mode 100644 tests/phpunit/data/db/mysql/functions.sql
create mode 100644 tests/phpunit/data/db/postgres/functions.sql
create mode 100644 tests/phpunit/data/db/sqlite/tables-1.13.sql
create mode 100644 tests/phpunit/data/db/sqlite/tables-1.15.sql
create mode 100644 tests/phpunit/data/db/sqlite/tables-1.16.sql
create mode 100644 tests/phpunit/data/db/sqlite/tables-1.17.sql
create mode 100644 tests/phpunit/data/db/sqlite/tables-1.18.sql
create mode 100644 tests/phpunit/data/media/1bit-png.png
create mode 100644 tests/phpunit/data/media/80x60-2layers.xcf
create mode 100644 tests/phpunit/data/media/80x60-Greyscale.xcf
create mode 100644 tests/phpunit/data/media/80x60-RGB.xcf
create mode 100644 tests/phpunit/data/media/Animated_PNG_example_bouncing_beach_ball.png
create mode 100644 tests/phpunit/data/media/Gtk-media-play-ltr.svg
create mode 100644 tests/phpunit/data/media/Png-native-test.png
create mode 100644 tests/phpunit/data/media/QA_icon.svg
create mode 100644 tests/phpunit/data/media/README
create mode 100644 tests/phpunit/data/media/Toll_Texas_1.svg
create mode 100644 tests/phpunit/data/media/US_states_by_total_state_tax_revenue.svg
create mode 100644 tests/phpunit/data/media/Wikimedia-logo.svg
create mode 100644 tests/phpunit/data/media/Xmp-exif-multilingual_test.jpg
create mode 100644 tests/phpunit/data/media/animated-xmp.gif
create mode 100644 tests/phpunit/data/media/animated.gif
create mode 100644 tests/phpunit/data/media/broken_exif_date.jpg
create mode 100644 tests/phpunit/data/media/exif-gps.jpg
create mode 100644 tests/phpunit/data/media/exif-user-comment.jpg
create mode 100644 tests/phpunit/data/media/greyscale-na-png.png
create mode 100644 tests/phpunit/data/media/greyscale-png.png
create mode 100644 tests/phpunit/data/media/iptc-invalid-psir.jpg
create mode 100644 tests/phpunit/data/media/iptc-timetest-invalid.jpg
create mode 100644 tests/phpunit/data/media/iptc-timetest.jpg
create mode 100644 tests/phpunit/data/media/jpeg-comment-binary.jpg
create mode 100644 tests/phpunit/data/media/jpeg-comment-iso8859-1.jpg
create mode 100644 tests/phpunit/data/media/jpeg-comment-multiple.jpg
create mode 100644 tests/phpunit/data/media/jpeg-comment-utf.jpg
create mode 100644 tests/phpunit/data/media/jpeg-iptc-bad-hash.jpg
create mode 100644 tests/phpunit/data/media/jpeg-iptc-good-hash.jpg
create mode 100644 tests/phpunit/data/media/jpeg-padding-even.jpg
create mode 100644 tests/phpunit/data/media/jpeg-padding-odd.jpg
create mode 100644 tests/phpunit/data/media/jpeg-xmp-alt.jpg
create mode 100644 tests/phpunit/data/media/jpeg-xmp-psir.jpg
create mode 100644 tests/phpunit/data/media/jpeg-xmp-psir.xmp
create mode 100644 tests/phpunit/data/media/landscape-plain.jpg
create mode 100644 tests/phpunit/data/media/nonanimated.gif
create mode 100644 tests/phpunit/data/media/portrait-rotated.jpg
create mode 100644 tests/phpunit/data/media/rgb-na-png.png
create mode 100644 tests/phpunit/data/media/rgb-png.png
create mode 100644 tests/phpunit/data/media/test.jpg
create mode 100644 tests/phpunit/data/media/test.tiff
create mode 100644 tests/phpunit/data/media/xmp.png
create mode 100644 tests/phpunit/data/xmp/1.result.php
create mode 100644 tests/phpunit/data/xmp/1.xmp
create mode 100644 tests/phpunit/data/xmp/2.result.php
create mode 100644 tests/phpunit/data/xmp/2.xmp
create mode 100644 tests/phpunit/data/xmp/3-invalid.result.php
create mode 100644 tests/phpunit/data/xmp/3-invalid.xmp
create mode 100644 tests/phpunit/data/xmp/3.result.php
create mode 100644 tests/phpunit/data/xmp/3.xmp
create mode 100644 tests/phpunit/data/xmp/4.result.php
create mode 100644 tests/phpunit/data/xmp/4.xmp
create mode 100644 tests/phpunit/data/xmp/5.result.php
create mode 100644 tests/phpunit/data/xmp/5.xmp
create mode 100644 tests/phpunit/data/xmp/6.result.php
create mode 100644 tests/phpunit/data/xmp/6.xmp
create mode 100644 tests/phpunit/data/xmp/7.result.php
create mode 100644 tests/phpunit/data/xmp/7.xmp
create mode 100644 tests/phpunit/data/xmp/README
create mode 100644 tests/phpunit/data/xmp/bag-for-seq.result.php
create mode 100644 tests/phpunit/data/xmp/bag-for-seq.xmp
create mode 100644 tests/phpunit/data/xmp/flash.result.php
create mode 100644 tests/phpunit/data/xmp/flash.xmp
create mode 100644 tests/phpunit/data/xmp/gps.result.php
create mode 100644 tests/phpunit/data/xmp/gps.xmp
create mode 100644 tests/phpunit/data/xmp/invalid-child-not-struct.result.php
create mode 100644 tests/phpunit/data/xmp/invalid-child-not-struct.xmp
create mode 100644 tests/phpunit/data/xmp/no-namespace.result.php
create mode 100644 tests/phpunit/data/xmp/no-namespace.xmp
create mode 100644 tests/phpunit/data/xmp/no-recognized-props.result.php
create mode 100644 tests/phpunit/data/xmp/no-recognized-props.xmp
create mode 100644 tests/phpunit/data/xmp/utf16BE.result.php
create mode 100644 tests/phpunit/data/xmp/utf16BE.xmp
create mode 100644 tests/phpunit/data/xmp/utf16LE.result.php
create mode 100644 tests/phpunit/data/xmp/utf16LE.xmp
create mode 100644 tests/phpunit/data/xmp/utf32BE.result.php
create mode 100644 tests/phpunit/data/xmp/utf32BE.xmp
create mode 100644 tests/phpunit/data/xmp/utf32LE.result.php
create mode 100644 tests/phpunit/data/xmp/utf32LE.xmp
create mode 100644 tests/phpunit/data/xmp/xmpExt.result.php
create mode 100644 tests/phpunit/data/xmp/xmpExt.xmp
create mode 100644 tests/phpunit/data/xmp/xmpExt2.xmp
create mode 100644 tests/phpunit/data/zip/cd-gap.zip
create mode 100644 tests/phpunit/data/zip/cd-truncated.zip
create mode 100644 tests/phpunit/data/zip/class-trailing-null.zip
create mode 100644 tests/phpunit/data/zip/class-trailing-slash.zip
create mode 100644 tests/phpunit/data/zip/class.zip
create mode 100644 tests/phpunit/data/zip/empty.zip
create mode 100644 tests/phpunit/data/zip/looks-like-zip64.zip
create mode 100644 tests/phpunit/data/zip/nosig.zip
create mode 100644 tests/phpunit/data/zip/split.zip
create mode 100644 tests/phpunit/data/zip/trail.zip
create mode 100644 tests/phpunit/data/zip/wrong-cd-start-disk.zip
create mode 100644 tests/phpunit/data/zip/wrong-central-entry-sig.zip
create mode 100644 tests/phpunit/docs/ExportDemoTest.php
create mode 100644 tests/phpunit/includes/ArticleTablesTest.php
create mode 100644 tests/phpunit/includes/ArticleTest.php
create mode 100644 tests/phpunit/includes/BlockTest.php
create mode 100644 tests/phpunit/includes/CdbTest.php
create mode 100644 tests/phpunit/includes/CollationTest.php
create mode 100644 tests/phpunit/includes/DiffHistoryBlobTest.php
create mode 100644 tests/phpunit/includes/EditPageTest.php
create mode 100644 tests/phpunit/includes/ExternalStoreTest.php
create mode 100644 tests/phpunit/includes/ExtraParserTest.php
create mode 100644 tests/phpunit/includes/FauxResponseTest.php
create mode 100644 tests/phpunit/includes/FormOptionsInitializationTest.php
create mode 100644 tests/phpunit/includes/FormOptionsTest.php
create mode 100644 tests/phpunit/includes/GlobalFunctions/GlobalTest.php
create mode 100644 tests/phpunit/includes/GlobalFunctions/GlobalWithDBTest.php
create mode 100644 tests/phpunit/includes/GlobalFunctions/README
create mode 100644 tests/phpunit/includes/GlobalFunctions/wfAssembleUrlTest.php
create mode 100644 tests/phpunit/includes/GlobalFunctions/wfBCP47Test.php
create mode 100644 tests/phpunit/includes/GlobalFunctions/wfBaseConvertTest.php
create mode 100644 tests/phpunit/includes/GlobalFunctions/wfBaseNameTest.php
create mode 100644 tests/phpunit/includes/GlobalFunctions/wfExpandUrlTest.php
create mode 100644 tests/phpunit/includes/GlobalFunctions/wfGetCallerTest.php
create mode 100644 tests/phpunit/includes/GlobalFunctions/wfParseUrlTest.php
create mode 100644 tests/phpunit/includes/GlobalFunctions/wfRemoveDotSegmentsTest.php
create mode 100644 tests/phpunit/includes/GlobalFunctions/wfShorthandToIntegerTest.php
create mode 100644 tests/phpunit/includes/GlobalFunctions/wfTimestampTest.php
create mode 100644 tests/phpunit/includes/GlobalFunctions/wfUrlencodeTest.php
create mode 100644 tests/phpunit/includes/HooksTest.php
create mode 100644 tests/phpunit/includes/HtmlTest.php
create mode 100644 tests/phpunit/includes/HttpTest.php
create mode 100644 tests/phpunit/includes/IPTest.php
create mode 100644 tests/phpunit/includes/JsonTest.php
create mode 100644 tests/phpunit/includes/LanguageConverterTest.php
create mode 100644 tests/phpunit/includes/LicensesTest.php
create mode 100644 tests/phpunit/includes/LinkerTest.php
create mode 100644 tests/phpunit/includes/LinksUpdateTest.php
create mode 100644 tests/phpunit/includes/LocalFileTest.php
create mode 100644 tests/phpunit/includes/LocalisationCacheTest.php
create mode 100644 tests/phpunit/includes/MWFunctionTest.php
create mode 100644 tests/phpunit/includes/MWNamespaceTest.php
create mode 100644 tests/phpunit/includes/MessageTest.php
create mode 100644 tests/phpunit/includes/OutputPageTest.php
create mode 100644 tests/phpunit/includes/PathRouterTest.php
create mode 100644 tests/phpunit/includes/PreferencesTest.php
create mode 100644 tests/phpunit/includes/Providers.php
create mode 100644 tests/phpunit/includes/RecentChangeTest.php
create mode 100644 tests/phpunit/includes/RequestContextTest.php
create mode 100644 tests/phpunit/includes/ResourceLoaderTest.php
create mode 100644 tests/phpunit/includes/RevisionStorageTest.php
create mode 100644 tests/phpunit/includes/RevisionStorageTest_ContentHandlerUseDB.php
create mode 100644 tests/phpunit/includes/RevisionTest.php
create mode 100644 tests/phpunit/includes/SampleTest.php
create mode 100644 tests/phpunit/includes/SanitizerTest.php
create mode 100644 tests/phpunit/includes/SanitizerValidateEmailTest.php
create mode 100644 tests/phpunit/includes/SeleniumConfigurationTest.php
create mode 100644 tests/phpunit/includes/SiteConfigurationTest.php
create mode 100644 tests/phpunit/includes/StringUtilsTest.php
create mode 100644 tests/phpunit/includes/TemplateCategoriesTest.php
create mode 100644 tests/phpunit/includes/TestUser.php
create mode 100644 tests/phpunit/includes/TimeAdjustTest.php
create mode 100644 tests/phpunit/includes/TimestampTest.php
create mode 100644 tests/phpunit/includes/TitleMethodsTest.php
create mode 100644 tests/phpunit/includes/TitlePermissionTest.php
create mode 100644 tests/phpunit/includes/TitleTest.php
create mode 100644 tests/phpunit/includes/UIDGeneratorTest.php
create mode 100644 tests/phpunit/includes/UserTest.php
create mode 100644 tests/phpunit/includes/WebRequestTest.php
create mode 100644 tests/phpunit/includes/WikiPageTest.php
create mode 100644 tests/phpunit/includes/WikiPageTest_ContentHandlerUseDB.php
create mode 100644 tests/phpunit/includes/XmlJsTest.php
create mode 100644 tests/phpunit/includes/XmlSelectTest.php
create mode 100644 tests/phpunit/includes/XmlTest.php
create mode 100644 tests/phpunit/includes/ZipDirectoryReaderTest.php
create mode 100644 tests/phpunit/includes/api/ApiAccountCreationTest.php
create mode 100644 tests/phpunit/includes/api/ApiBlockTest.php
create mode 100644 tests/phpunit/includes/api/ApiEditPageTest.php
create mode 100644 tests/phpunit/includes/api/ApiOptionsTest.php
create mode 100644 tests/phpunit/includes/api/ApiParseTest.php
create mode 100644 tests/phpunit/includes/api/ApiPurgeTest.php
create mode 100644 tests/phpunit/includes/api/ApiTest.php
create mode 100644 tests/phpunit/includes/api/ApiTestCase.php
create mode 100644 tests/phpunit/includes/api/ApiTestCaseUpload.php
create mode 100644 tests/phpunit/includes/api/ApiUploadTest.php
create mode 100644 tests/phpunit/includes/api/ApiWatchTest.php
create mode 100644 tests/phpunit/includes/api/PrefixUniquenessTest.php
create mode 100644 tests/phpunit/includes/api/RandomImageGenerator.php
create mode 100644 tests/phpunit/includes/api/format/ApiFormatPhpTest.php
create mode 100644 tests/phpunit/includes/api/format/ApiFormatTestBase.php
create mode 100644 tests/phpunit/includes/api/generateRandomImages.php
create mode 100644 tests/phpunit/includes/api/query/ApiQueryBasicTest.php
create mode 100644 tests/phpunit/includes/api/query/ApiQueryContinue2Test.php
create mode 100644 tests/phpunit/includes/api/query/ApiQueryContinueTest.php
create mode 100644 tests/phpunit/includes/api/query/ApiQueryContinueTestBase.php
create mode 100644 tests/phpunit/includes/api/query/ApiQueryRevisionsTest.php
create mode 100644 tests/phpunit/includes/api/query/ApiQueryTest.php
create mode 100644 tests/phpunit/includes/api/query/ApiQueryTestBase.php
create mode 100644 tests/phpunit/includes/api/words.txt
create mode 100644 tests/phpunit/includes/cache/GenderCacheTest.php
create mode 100644 tests/phpunit/includes/cache/ProcessCacheLRUTest.php
create mode 100644 tests/phpunit/includes/content/ContentHandlerTest.php
create mode 100644 tests/phpunit/includes/content/CssContentTest.php
create mode 100644 tests/phpunit/includes/content/JavaScriptContentTest.php
create mode 100644 tests/phpunit/includes/content/TextContentTest.php
create mode 100644 tests/phpunit/includes/content/WikitextContentHandlerTest.php
create mode 100644 tests/phpunit/includes/content/WikitextContentTest.php
create mode 100644 tests/phpunit/includes/db/DatabaseSQLTest.php
create mode 100644 tests/phpunit/includes/db/DatabaseSqliteTest.php
create mode 100644 tests/phpunit/includes/db/DatabaseTest.php
create mode 100644 tests/phpunit/includes/db/ORMRowTest.php
create mode 100644 tests/phpunit/includes/db/ORMTableTest.php
create mode 100644 tests/phpunit/includes/db/TestORMRowTest.php
create mode 100644 tests/phpunit/includes/debug/MWDebugTest.php
create mode 100644 tests/phpunit/includes/filebackend/FileBackendTest.php
create mode 100644 tests/phpunit/includes/filerepo/FileRepoTest.php
create mode 100644 tests/phpunit/includes/filerepo/StoreBatchTest.php
create mode 100644 tests/phpunit/includes/installer/InstallDocFormatterTest.php
create mode 100644 tests/phpunit/includes/jobqueue/JobQueueTest.php
create mode 100644 tests/phpunit/includes/json/ServicesJsonTest.php
create mode 100644 tests/phpunit/includes/libs/CSSJanusTest.php
create mode 100644 tests/phpunit/includes/libs/CSSMinTest.php
create mode 100644 tests/phpunit/includes/libs/GenericArrayObjectTest.php
create mode 100644 tests/phpunit/includes/libs/IEUrlExtensionTest.php
create mode 100644 tests/phpunit/includes/libs/JavaScriptMinifierTest.php
create mode 100644 tests/phpunit/includes/logging/LogFormatterTest.php
create mode 100644 tests/phpunit/includes/logging/LogTests.i18n.php
create mode 100644 tests/phpunit/includes/media/BitmapMetadataHandlerTest.php
create mode 100644 tests/phpunit/includes/media/BitmapScalingTest.php
create mode 100644 tests/phpunit/includes/media/ExifBitmapTest.php
create mode 100644 tests/phpunit/includes/media/ExifRotationTest.php
create mode 100644 tests/phpunit/includes/media/ExifTest.php
create mode 100644 tests/phpunit/includes/media/FormatMetadataTest.php
create mode 100644 tests/phpunit/includes/media/GIFMetadataExtractorTest.php
create mode 100644 tests/phpunit/includes/media/GIFTest.php
create mode 100644 tests/phpunit/includes/media/IPTCTest.php
create mode 100644 tests/phpunit/includes/media/JpegMetadataExtractorTest.php
create mode 100644 tests/phpunit/includes/media/JpegTest.php
create mode 100644 tests/phpunit/includes/media/MediaHandlerTest.php
create mode 100644 tests/phpunit/includes/media/PNGMetadataExtractorTest.php
create mode 100644 tests/phpunit/includes/media/PNGTest.php
create mode 100644 tests/phpunit/includes/media/SVGMetadataExtractorTest.php
create mode 100644 tests/phpunit/includes/media/TiffTest.php
create mode 100644 tests/phpunit/includes/media/XMPTest.php
create mode 100644 tests/phpunit/includes/media/XMPValidateTest.php
create mode 100644 tests/phpunit/includes/normal/CleanUpTest.php
create mode 100644 tests/phpunit/includes/objectcache/BagOStuffTest.php
create mode 100644 tests/phpunit/includes/parser/MagicVariableTest.php
create mode 100644 tests/phpunit/includes/parser/MediaWikiParserTest.php
create mode 100644 tests/phpunit/includes/parser/NewParserTest.php
create mode 100644 tests/phpunit/includes/parser/ParserMethodsTest.php
create mode 100644 tests/phpunit/includes/parser/ParserOutputTest.php
create mode 100644 tests/phpunit/includes/parser/ParserPreloadTest.php
create mode 100644 tests/phpunit/includes/parser/PreprocessorTest.php
create mode 100644 tests/phpunit/includes/parser/TagHooksTest.php
create mode 100644 tests/phpunit/includes/search/SearchEngineTest.php
create mode 100644 tests/phpunit/includes/search/SearchUpdateTest.php
create mode 100644 tests/phpunit/includes/site/MediaWikiSiteTest.php
create mode 100644 tests/phpunit/includes/site/SiteListTest.php
create mode 100644 tests/phpunit/includes/site/SiteSQLStoreTest.php
create mode 100644 tests/phpunit/includes/site/SiteTest.php
create mode 100644 tests/phpunit/includes/site/TestSites.php
create mode 100644 tests/phpunit/includes/specials/QueryAllSpecialPagesTest.php
create mode 100644 tests/phpunit/includes/specials/SpecialRecentchangesTest.php
create mode 100644 tests/phpunit/includes/specials/SpecialSearchTest.php
create mode 100644 tests/phpunit/includes/upload/UploadFromUrlTest.php
create mode 100644 tests/phpunit/includes/upload/UploadStashTest.php
create mode 100644 tests/phpunit/includes/upload/UploadTest.php
create mode 100644 tests/phpunit/install-phpunit.sh
create mode 100644 tests/phpunit/languages/LanguageAmTest.php
create mode 100644 tests/phpunit/languages/LanguageArTest.php
create mode 100644 tests/phpunit/languages/LanguageBeTest.php
create mode 100644 tests/phpunit/languages/LanguageBe_taraskTest.php
create mode 100644 tests/phpunit/languages/LanguageBhoTest.php
create mode 100644 tests/phpunit/languages/LanguageBsTest.php
create mode 100644 tests/phpunit/languages/LanguageClassesTestCase.php
create mode 100644 tests/phpunit/languages/LanguageCsTest.php
create mode 100644 tests/phpunit/languages/LanguageCuTest.php
create mode 100644 tests/phpunit/languages/LanguageCyTest.php
create mode 100644 tests/phpunit/languages/LanguageDsbTest.php
create mode 100644 tests/phpunit/languages/LanguageFrTest.php
create mode 100644 tests/phpunit/languages/LanguageGaTest.php
create mode 100644 tests/phpunit/languages/LanguageGdTest.php
create mode 100644 tests/phpunit/languages/LanguageGvTest.php
create mode 100644 tests/phpunit/languages/LanguageHeTest.php
create mode 100644 tests/phpunit/languages/LanguageHiTest.php
create mode 100644 tests/phpunit/languages/LanguageHrTest.php
create mode 100644 tests/phpunit/languages/LanguageHsbTest.php
create mode 100644 tests/phpunit/languages/LanguageHuTest.php
create mode 100644 tests/phpunit/languages/LanguageHyTest.php
create mode 100644 tests/phpunit/languages/LanguageKshTest.php
create mode 100644 tests/phpunit/languages/LanguageLnTest.php
create mode 100644 tests/phpunit/languages/LanguageLtTest.php
create mode 100644 tests/phpunit/languages/LanguageLvTest.php
create mode 100644 tests/phpunit/languages/LanguageMgTest.php
create mode 100644 tests/phpunit/languages/LanguageMkTest.php
create mode 100644 tests/phpunit/languages/LanguageMlTest.php
create mode 100644 tests/phpunit/languages/LanguageMoTest.php
create mode 100644 tests/phpunit/languages/LanguageMtTest.php
create mode 100644 tests/phpunit/languages/LanguageNlTest.php
create mode 100644 tests/phpunit/languages/LanguageNsoTest.php
create mode 100644 tests/phpunit/languages/LanguagePlTest.php
create mode 100644 tests/phpunit/languages/LanguageRoTest.php
create mode 100644 tests/phpunit/languages/LanguageRuTest.php
create mode 100644 tests/phpunit/languages/LanguageSeTest.php
create mode 100644 tests/phpunit/languages/LanguageSgsTest.php
create mode 100644 tests/phpunit/languages/LanguageShTest.php
create mode 100644 tests/phpunit/languages/LanguageSkTest.php
create mode 100644 tests/phpunit/languages/LanguageSlTest.php
create mode 100644 tests/phpunit/languages/LanguageSmaTest.php
create mode 100644 tests/phpunit/languages/LanguageSrTest.php
create mode 100644 tests/phpunit/languages/LanguageTest.php
create mode 100644 tests/phpunit/languages/LanguageTiTest.php
create mode 100644 tests/phpunit/languages/LanguageTlTest.php
create mode 100644 tests/phpunit/languages/LanguageTrTest.php
create mode 100644 tests/phpunit/languages/LanguageUkTest.php
create mode 100644 tests/phpunit/languages/LanguageUzTest.php
create mode 100644 tests/phpunit/languages/LanguageWaTest.php
create mode 100644 tests/phpunit/languages/utils/CLDRPluralRuleEvaluatorTest.php
create mode 100644 tests/phpunit/maintenance/DumpTestCase.php
create mode 100644 tests/phpunit/maintenance/MaintenanceTest.php
create mode 100644 tests/phpunit/maintenance/backupPrefetchTest.php
create mode 100644 tests/phpunit/maintenance/backupTextPassTest.php
create mode 100644 tests/phpunit/maintenance/backup_LogTest.php
create mode 100644 tests/phpunit/maintenance/backup_PageTest.php
create mode 100644 tests/phpunit/maintenance/fetchTextTest.php
create mode 100644 tests/phpunit/maintenance/getSlaveServerTest.php
create mode 100644 tests/phpunit/phpunit.php
create mode 100644 tests/phpunit/resources/ResourcesTest.php
create mode 100644 tests/phpunit/run-tests.bat
create mode 100644 tests/phpunit/skins/SideBarTest.php
create mode 100644 tests/phpunit/suite.xml
create mode 100644 tests/phpunit/suites/ExtensionsTestSuite.php
create mode 100644 tests/phpunit/suites/UploadFromUrlTestSuite.php
create mode 100644 tests/qunit/.htaccess
create mode 100644 tests/qunit/QUnitTestResources.php
create mode 100644 tests/qunit/data/callMwLoaderTestCallback.js
create mode 100644 tests/qunit/data/generateJqueryMsgData.php
create mode 100644 tests/qunit/data/load.mock.php
create mode 100644 tests/qunit/data/mediawiki.jqueryMsg.data.js
create mode 100644 tests/qunit/data/qunitOkCall.js
create mode 100644 tests/qunit/data/styleTest.css.php
create mode 100644 tests/qunit/data/testrunner.js
create mode 100644 tests/qunit/suites/resources/jquery/jquery.autoEllipsis.test.js
create mode 100644 tests/qunit/suites/resources/jquery/jquery.byteLength.test.js
create mode 100644 tests/qunit/suites/resources/jquery/jquery.byteLimit.test.js
create mode 100644 tests/qunit/suites/resources/jquery/jquery.client.test.js
create mode 100644 tests/qunit/suites/resources/jquery/jquery.colorUtil.test.js
create mode 100644 tests/qunit/suites/resources/jquery/jquery.delayedBind.test.js
create mode 100644 tests/qunit/suites/resources/jquery/jquery.getAttrs.test.js
create mode 100644 tests/qunit/suites/resources/jquery/jquery.hidpi.test.js
create mode 100644 tests/qunit/suites/resources/jquery/jquery.highlightText.test.js
create mode 100644 tests/qunit/suites/resources/jquery/jquery.localize.test.js
create mode 100644 tests/qunit/suites/resources/jquery/jquery.mwExtension.test.js
create mode 100644 tests/qunit/suites/resources/jquery/jquery.tabIndex.test.js
create mode 100644 tests/qunit/suites/resources/jquery/jquery.tablesorter.test.js
create mode 100644 tests/qunit/suites/resources/jquery/jquery.textSelection.test.js
create mode 100644 tests/qunit/suites/resources/mediawiki.api/mediawiki.api.parse.test.js
create mode 100644 tests/qunit/suites/resources/mediawiki.api/mediawiki.api.test.js
create mode 100644 tests/qunit/suites/resources/mediawiki.special/mediawiki.special.recentchanges.test.js
create mode 100644 tests/qunit/suites/resources/mediawiki/mediawiki.Title.test.js
create mode 100644 tests/qunit/suites/resources/mediawiki/mediawiki.Uri.test.js
create mode 100644 tests/qunit/suites/resources/mediawiki/mediawiki.cldr.test.js
create mode 100644 tests/qunit/suites/resources/mediawiki/mediawiki.jqueryMsg.test.js
create mode 100644 tests/qunit/suites/resources/mediawiki/mediawiki.jscompat.test.js
create mode 100644 tests/qunit/suites/resources/mediawiki/mediawiki.language.test.js
create mode 100644 tests/qunit/suites/resources/mediawiki/mediawiki.test.js
create mode 100644 tests/qunit/suites/resources/mediawiki/mediawiki.user.test.js
create mode 100644 tests/qunit/suites/resources/mediawiki/mediawiki.util.test.js
create mode 100644 tests/selenium/Selenium.php
create mode 100644 tests/selenium/SeleniumConfig.php
create mode 100644 tests/selenium/SeleniumLoader.php
create mode 100644 tests/selenium/SeleniumServerManager.php
create mode 100644 tests/selenium/SeleniumTestCase.php
create mode 100644 tests/selenium/SeleniumTestConsoleLogger.php
create mode 100644 tests/selenium/SeleniumTestConstants.php
create mode 100644 tests/selenium/SeleniumTestHTMLLogger.php
create mode 100644 tests/selenium/SeleniumTestListener.php
create mode 100644 tests/selenium/SeleniumTestSuite.php
create mode 100644 tests/selenium/data/SimpleSeleniumTestDB.sql
create mode 100644 tests/selenium/data/SimpleSeleniumTestImages.zip
create mode 100644 tests/selenium/data/Wikipedia-logo-v2-de.png
create mode 100644 tests/selenium/data/mediawiki118_fresh_installation.sql
create mode 100644 tests/selenium/installer/MediaWikiButtonsAvailabilityTestCase.php
create mode 100644 tests/selenium/installer/MediaWikiDifferentDatabaseAccountTestCase.php
create mode 100644 tests/selenium/installer/MediaWikiDifferntDatabasePrefixTestCase.php
create mode 100644 tests/selenium/installer/MediaWikiErrorsConnectToDatabasePageTestCase.php
create mode 100644 tests/selenium/installer/MediaWikiErrorsNamepageTestCase.php
create mode 100644 tests/selenium/installer/MediaWikiHelpFieldHintTestCase.php
create mode 100644 tests/selenium/installer/MediaWikiInstallationCommonFunction.php
create mode 100644 tests/selenium/installer/MediaWikiInstallationConfig.php
create mode 100644 tests/selenium/installer/MediaWikiInstallationMessage.php
create mode 100644 tests/selenium/installer/MediaWikiInstallationVariables.php
create mode 100644 tests/selenium/installer/MediaWikiInstallerTestSuite.php
create mode 100644 tests/selenium/installer/MediaWikiMySQLDataBaseTestCase.php
create mode 100644 tests/selenium/installer/MediaWikiMySQLiteDataBaseTestCase.php
create mode 100644 tests/selenium/installer/MediaWikiOnAlreadyInstalledTestCase.php
create mode 100644 tests/selenium/installer/MediaWikiRestartInstallationTestCase.php
create mode 100644 tests/selenium/installer/MediaWikiRightFrameworkLinksTestCase.php
create mode 100644 tests/selenium/installer/MediaWikiUpgradeExistingDatabaseTestCase.php
create mode 100644 tests/selenium/installer/MediaWikiUserInterfaceTestCase.php
create mode 100644 tests/selenium/installer/README.txt
create mode 100644 tests/selenium/selenium_settings.ini.sample
create mode 100644 tests/selenium/selenium_settings_grid.ini.sample
create mode 100644 tests/selenium/suites/AddContentToNewPageTestCase.php
create mode 100644 tests/selenium/suites/AddNewPageTestCase.php
create mode 100644 tests/selenium/suites/CreateAccountTestCase.php
create mode 100644 tests/selenium/suites/DeletePageAdminTestCase.php
create mode 100644 tests/selenium/suites/EmailPasswordTestCase.php
create mode 100644 tests/selenium/suites/MediaWikiEditorConfig.php
create mode 100644 tests/selenium/suites/MediaWikiEditorTestSuite.php
create mode 100644 tests/selenium/suites/MediaWikiExtraTestSuite.php
create mode 100644 tests/selenium/suites/MediawikiCoreSmokeTestCase.php
create mode 100644 tests/selenium/suites/MediawikiCoreSmokeTestSuite.php
create mode 100644 tests/selenium/suites/MovePageTestCase.php
create mode 100644 tests/selenium/suites/MyContributionsTestCase.php
create mode 100644 tests/selenium/suites/MyWatchListTestCase.php
create mode 100644 tests/selenium/suites/PageDeleteTestSuite.php
create mode 100644 tests/selenium/suites/PageSearchTestCase.php
create mode 100644 tests/selenium/suites/PreviewPageTestCase.php
create mode 100644 tests/selenium/suites/SavePageTestCase.php
create mode 100644 tests/selenium/suites/SimpleSeleniumConfig.php
create mode 100644 tests/selenium/suites/SimpleSeleniumTestCase.php
create mode 100644 tests/selenium/suites/SimpleSeleniumTestSuite.php
create mode 100644 tests/selenium/suites/UserPreferencesTestCase.php
create mode 100644 tests/testHelpers.inc
(limited to 'tests/phpunit')
diff --git a/.gitreview b/.gitreview
new file mode 100644
index 00000000..65dbc270
--- /dev/null
+++ b/.gitreview
@@ -0,0 +1,6 @@
+[gerrit]
+host=gerrit.wikimedia.org
+port=29418
+project=mediawiki/core.git
+defaultbranch=REL1_21
+defaultrebase=0
diff --git a/.jshintignore b/.jshintignore
new file mode 100644
index 00000000..3869deb9
--- /dev/null
+++ b/.jshintignore
@@ -0,0 +1,27 @@
+# third-party libs
+extensions/
+node_modules/
+resources/jquery/jquery.appear.js
+resources/jquery/jquery.async.js
+resources/jquery/jquery.cycle.all.js
+resources/jquery/jquery.cookie.js
+resources/jquery/jquery.farbtastic.js
+resources/jquery/jquery.form.js
+resources/jquery/jquery.hoverIntent.js
+resources/jquery/jquery.js
+resources/jquery/jquery.json.js
+resources/jquery/jquery.jStorage.js
+resources/jquery/jquery.mockjax.js
+resources/jquery/jquery.qunit.js
+resources/jquery/jquery.validate.js
+resources/jquery/jquery.xmldom.js
+resources/jquery.effects/
+resources/jquery.tipsy/
+resources/jquery.ui/
+resources/mediawiki.libs/
+
+# legacy scripts
+skins/common/
+
+# github.com/jshint/jshint/issues/729
+tests/qunit/suites/resources/mediawiki/mediawiki.jscompat.test.js
diff --git a/.jshintrc b/.jshintrc
new file mode 100644
index 00000000..7fa138d4
--- /dev/null
+++ b/.jshintrc
@@ -0,0 +1,34 @@
+{
+ "predef": [
+ "mediaWiki",
+ "jQuery",
+ "QUnit"
+ ],
+
+ "bitwise": true,
+ "camelcase": true,
+ "curly": true,
+ "eqeqeq": true,
+ "forin": false,
+ "immed": true,
+ "latedef": true,
+ "newcap": true,
+ "noarg": true,
+ "noempty": true,
+ "nonew": true,
+ "quotmark": "single",
+ "regexp": false,
+ "undef": true,
+ "unused": true,
+ "strict": false,
+ "trailing": true,
+
+ "laxbreak": true,
+ "smarttabs": true,
+ "multistr": true,
+
+ "browser": true,
+
+ "nomen": true,
+ "onevar": true
+}
diff --git a/RELEASE-NOTES-1.21 b/RELEASE-NOTES-1.21
index ef4f08c6..4e08480f 100644
--- a/RELEASE-NOTES-1.21
+++ b/RELEASE-NOTES-1.21
@@ -3,11 +3,25 @@
Security reminder: MediaWiki does not require PHP's register_globals. If you
have it on, turn it '''off''' if you can.
+== MediaWiki 1.21.2 ==
+
+This is a security adn maintenance release of the MediaWiki 1.21 branch.
+
+=== Changes since 1.21.1 ===
+
+* SECURITY: Fix extension detection with 2 .'s
+* SECURITY: Support for the 'gettoken' parameter to action=block and action=unblock,
+ deprecated since 1.20, has been removed.
+* SECURITY: Sanitize ResourceLoader exception messages
+* Purge upstream caches when deleting file assets.
+* Unit test suite now runs the AutoLoader tests. Also fixed the autoloading
+ entry for the PageORMTableForTesting class though it had no impact.
+
== MediaWiki 1.21.1 ==
This is a maintenance release of the 1.21 branch.
-MediaWiki 1.21 is an stable branch and is recommended for use in production.
+MediaWiki 1.21 is a stable branch, and is recommended for use in production.
=== Changes since 1.21.0 ===
diff --git a/extensions/Cite/.gitreview b/extensions/Cite/.gitreview
new file mode 100644
index 00000000..6ae9db41
--- /dev/null
+++ b/extensions/Cite/.gitreview
@@ -0,0 +1,5 @@
+[gerrit]
+host=gerrit.wikimedia.org
+port=29418
+project=mediawiki/extensions/Cite.git
+defaultbranch=master
diff --git a/extensions/ConfirmEdit/.gitreview b/extensions/ConfirmEdit/.gitreview
new file mode 100644
index 00000000..780d35df
--- /dev/null
+++ b/extensions/ConfirmEdit/.gitreview
@@ -0,0 +1,5 @@
+[gerrit]
+host=gerrit.wikimedia.org
+port=29418
+project=mediawiki/extensions/ConfirmEdit.git
+defaultbranch=master
diff --git a/extensions/ConfirmEdit/ReCaptcha.i18n.php b/extensions/ConfirmEdit/ReCaptcha.i18n.php
index a7fffb59..e8722f93 100644
--- a/extensions/ConfirmEdit/ReCaptcha.i18n.php
+++ b/extensions/ConfirmEdit/ReCaptcha.i18n.php
@@ -400,13 +400,12 @@ $messages['nl-informal'] = array(
);
/** Polish (polski)
- * @author WTM
*/
$messages['pl'] = array(
'recaptcha-edit' => 'Aby uchronić nas przed robotami, proszę wpisać dwa widoczne słowa w poniższym polu:',
'recaptcha-addurl' => 'Twoja edycja zawiera linki zewnętrzne. Aby uchronić nas przed robotami, proszę wpisać dwa widoczne słowa w poniższym polu:',
'recaptcha-badpass' => 'Aby uchronić nas przed złamaniem automatycznym haseł, proszę wpisać dwa widoczne słowa w poniższym polu:',
- 'recaptcha-createaccount' => 'Aby uchronić nas przed automatycznym tworzeniem użytkowników, proszę wpisać dwa widoczne słowa w poniższym polu:',
+ 'recaptcha-createaccount' => 'Aby uchronić nas przed automatycznym stworzeniem użytkowników, proszę wpisać dwa widoczne słowa w poniższym polu:',
'recaptcha-createaccount-fail' => 'Odpowiedź na reCAPTCHA jest fałszywa lub brakująca.',
'recaptcha-create' => 'Aby uchronić nas przed tworzeniem stron przez robotów, proszę wpisać dwa widoczne słowa w poniższym polu:',
);
diff --git a/extensions/Gadgets/.gitreview b/extensions/Gadgets/.gitreview
new file mode 100644
index 00000000..a1a8ead4
--- /dev/null
+++ b/extensions/Gadgets/.gitreview
@@ -0,0 +1,5 @@
+[gerrit]
+host=gerrit.wikimedia.org
+port=29418
+project=mediawiki/extensions/Gadgets.git
+defaultbranch=master
diff --git a/extensions/Gadgets/tests/GadgetTest.php b/extensions/Gadgets/tests/GadgetTest.php
new file mode 100644
index 00000000..c9332a6c
--- /dev/null
+++ b/extensions/Gadgets/tests/GadgetTest.php
@@ -0,0 +1,81 @@
+assertEquals( 'Gadget', get_class( $g ) );
+
+ return $g;
+ }
+
+ function testInvalidLines() {
+ $this->assertFalse( Gadget::newFromDefinition( '' ) );
+ $this->assertFalse( Gadget::newFromDefinition( '' ) );
+ }
+
+ function testSimpleCases() {
+ $g = $this->create( '* foo bar| foo.css|foo.js|foo.bar' );
+ $this->assertEquals( 'foo_bar', $g->getName() );
+ $this->assertEquals( 'ext.gadget.foo_bar', $g->getModuleName() );
+ $this->assertEquals( array( 'Gadget-foo.js' ), $g->getScripts() );
+ $this->assertEquals( array( 'Gadget-foo.css' ), $g->getStyles() );
+ $this->assertEquals( array( 'Gadget-foo.js', 'Gadget-foo.css' ),
+ $g->getScriptsAndStyles() );
+ $this->assertEquals( array( 'Gadget-foo.js' ), $g->getLegacyScripts() );
+ $this->assertFalse( $g->supportsResourceLoader() );
+ $this->assertTrue( $g->hasModule() );
+ }
+
+ function testRLtag() {
+ $g = $this->create( '*foo [ResourceLoader]|foo.js|foo.css' );
+ $this->assertEquals( 'foo', $g->getName() );
+ $this->assertTrue( $g->supportsResourceLoader() );
+ $this->assertEquals( 0, count( $g->getLegacyScripts() ) );
+ }
+
+ function testDependencies() {
+ $g = $this->create( '* foo[ResourceLoader|dependencies=jquery.ui]|bar.js' );
+ $this->assertEquals( array( 'Gadget-bar.js' ), $g->getScripts() );
+ $this->assertTrue( $g->supportsResourceLoader() );
+ $this->assertEquals( array( 'jquery.ui' ), $g->getDependencies() );
+ }
+
+ function testPreferences() {
+ global $wgUser, $wgOut, $wgTitle;
+
+ // This test makes call to the parser which requires valids Outputpage
+ // and Title objects. Set them up there, they will be released at the
+ // end of the test.
+ $old_wgOut = $wgOut;
+ $old_wgTitle = $wgTitle;
+ $wgTitle = Title::newFromText( 'Parser test for Gadgets extension' );
+
+ // Proceed with test setup:
+ $prefs = array();
+ $context = new RequestContext();
+ $wgOut = $context->getOutput();
+ $wgOut->setTitle( Title::newFromText( 'test' ) );
+
+ Gadget::loadStructuredList( '* foo | foo.js
+==keep-section1==
+* bar| bar.js
+==remove-section==
+* baz [rights=embezzle] |baz.js
+==keep-section2==
+* quux [rights=read] | quux.js' );
+ $this->assertTrue( GadgetHooks::getPreferences( $wgUser, $prefs ), 'GetPrefences hook should return true' );
+
+ $options = $prefs['gadgets']['options'];
+ $this->assertFalse( isset( $options['<gadget-section-remove-section>'] ), 'Must not show empty sections' );
+ $this->assertTrue( isset( $options['<gadget-section-keep-section1>'] ) );
+ $this->assertTrue( isset( $options['<gadget-section-keep-section2>'] ) );
+
+ // Restore globals
+ $wgOut = $old_wgOut;
+ $wgTitle = $old_wgTitle;
+ }
+}
diff --git a/extensions/ImageMap/.gitreview b/extensions/ImageMap/.gitreview
new file mode 100644
index 00000000..2629c9d9
--- /dev/null
+++ b/extensions/ImageMap/.gitreview
@@ -0,0 +1,5 @@
+[gerrit]
+host=gerrit.wikimedia.org
+port=29418
+project=mediawiki/extensions/ImageMap.git
+defaultbranch=master
diff --git a/extensions/InputBox/.gitreview b/extensions/InputBox/.gitreview
new file mode 100644
index 00000000..9d0c704d
--- /dev/null
+++ b/extensions/InputBox/.gitreview
@@ -0,0 +1,5 @@
+[gerrit]
+host=gerrit.wikimedia.org
+port=29418
+project=mediawiki/extensions/InputBox.git
+defaultbranch=master
diff --git a/extensions/Interwiki/.gitreview b/extensions/Interwiki/.gitreview
new file mode 100644
index 00000000..fcc03f61
--- /dev/null
+++ b/extensions/Interwiki/.gitreview
@@ -0,0 +1,6 @@
+[gerrit]
+host=gerrit.wikimedia.org
+port=29418
+project=mediawiki/extensions/Interwiki.git
+defaultbranch=master
+defaultrebase=0
\ No newline at end of file
diff --git a/extensions/LocalisationUpdate/.gitreview b/extensions/LocalisationUpdate/.gitreview
new file mode 100644
index 00000000..da37d04d
--- /dev/null
+++ b/extensions/LocalisationUpdate/.gitreview
@@ -0,0 +1,5 @@
+[gerrit]
+host=gerrit.wikimedia.org
+port=29418
+project=mediawiki/extensions/LocalisationUpdate.git
+defaultbranch=master
diff --git a/extensions/LocalisationUpdate/tests/tokenTest.php b/extensions/LocalisationUpdate/tests/tokenTest.php
new file mode 100644
index 00000000..1112313c
--- /dev/null
+++ b/extensions/LocalisationUpdate/tests/tokenTest.php
@@ -0,0 +1,91 @@
+getVars();
+ $retval = @$vars[$varname];
+ } catch( Exception $e ) {
+ print $e . "\n";
+ $retval = null;
+ }
+ return $retval;
+}
+
+function quickTokenExtractArray( $php, $varname ) {
+ $reader = new QuickArrayReader("getVar( $varname );
+}
+
+
+if( count( $args ) ) {
+ $sources = $args;
+} else {
+ $sources =
+ array_merge(
+ glob("$IP/extensions/*/*.i18n.php"),
+ glob("$IP/languages/messages/Messages*.php") );
+}
+
+foreach( $sources as $sourceFile ) {
+ $rel = basename( $sourceFile );
+ $out = str_replace( '/', '-', $rel );
+
+ $sourceData = file_get_contents( $sourceFile );
+
+ if( preg_match( '!extensions/!', $sourceFile ) ) {
+ $sourceData = LocalisationUpdate::cleanupExtensionFile( $sourceData );
+ $items = 'langs';
+ } else {
+ $sourceData = LocalisationUpdate::cleanupFile( $sourceData );
+ $items = 'messages';
+ }
+
+ file_put_contents( "$out.txt", $sourceData );
+
+ $start = microtime(true);
+ $eval = evalExtractArray( $sourceData, 'messages' );
+ $deltaEval = microtime(true) - $start;
+
+ $start = microtime(true);
+ $quick = quickTokenExtractArray( $sourceData, 'messages' );
+ $deltaQuick = microtime(true) - $start;
+
+ $start = microtime(true);
+ $token = confExtractArray( $sourceData, 'messages' );
+ $deltaToken = microtime(true) - $start;
+
+ $hashEval = md5(serialize($eval));
+ $hashToken = md5(serialize($token));
+ $hashQuick = md5(serialize($quick));
+ $countEval = count( (array)$eval);
+ $countToken = count( (array)$token );
+ $countQuick = count( (array)$quick );
+
+ printf( "%s %s %d $items - %0.1fms - eval\n", $rel, $hashEval, $countEval, $deltaEval * 1000 );
+ printf( "%s %s %d $items - %0.1fms - QuickArrayReader\n", $rel, $hashQuick, $countQuick, $deltaQuick * 1000 );
+ printf( "%s %s %d $items - %0.1fms - ConfEditor\n", $rel, $hashToken, $countToken, $deltaToken * 1000 );
+
+ if( $hashEval !== $hashToken || $hashEval !== $hashQuick ) {
+ echo "FAILED on $rel\n";
+ file_put_contents( "$out-eval.txt", var_export( $eval, true ) );
+ file_put_contents( "$out-token.txt", var_export( $token, true ) );
+ file_put_contents( "$out-quick.txt", var_export( $quick, true ) );
+ #die("check eval.txt and token.txt\n");
+ }
+ echo "\n";
+}
+
+echo "ok\n";
+
diff --git a/extensions/Nuke/.gitreview b/extensions/Nuke/.gitreview
new file mode 100644
index 00000000..c623aede
--- /dev/null
+++ b/extensions/Nuke/.gitreview
@@ -0,0 +1,5 @@
+[gerrit]
+host=gerrit.wikimedia.org
+port=29418
+project=mediawiki/extensions/Nuke.git
+defaultbranch=master
diff --git a/extensions/ParserFunctions/.gitreview b/extensions/ParserFunctions/.gitreview
new file mode 100644
index 00000000..decb9867
--- /dev/null
+++ b/extensions/ParserFunctions/.gitreview
@@ -0,0 +1,5 @@
+[gerrit]
+host=gerrit.wikimedia.org
+port=29418
+project=mediawiki/extensions/ParserFunctions.git
+defaultbranch=master
diff --git a/extensions/ParserFunctions/ParserFunctions.i18n.magic.php b/extensions/ParserFunctions/ParserFunctions.i18n.magic.php
index 1a37cf9e..4fdb83eb 100644
--- a/extensions/ParserFunctions/ParserFunctions.i18n.magic.php
+++ b/extensions/ParserFunctions/ParserFunctions.i18n.magic.php
@@ -96,8 +96,8 @@ $magicWords['br'] = array(
/** Chechen (нохчийн) */
$magicWords['ce'] = array(
- 'time' => array( 0, 'хан' ),
- 'replace' => array( 0, 'хийцарна', 'замена' ),
+ 'time' => array( 0, 'хан', 'time' ),
+ 'replace' => array( 0, 'хийцарна', 'замена', 'replace' ),
);
/** Czech (česky) */
diff --git a/extensions/ParserFunctions/tests/ExpressionTest.php b/extensions/ParserFunctions/tests/ExpressionTest.php
new file mode 100644
index 00000000..169a9cb4
--- /dev/null
+++ b/extensions/ParserFunctions/tests/ExpressionTest.php
@@ -0,0 +1,76 @@
+parser = new ExprParser();
+ }
+
+ /**
+ * @dataProvider provideExpressions
+ */
+ function testExpression( $input, $expected ) {
+ $this->assertEquals(
+ $expected,
+ $this->parser->doExpression( $input )
+ );
+ }
+
+ function provideExpressions() {
+ return array(
+ array( '1 or 0', '1' ),
+ array( 'not (1 and 0)', '1' ),
+ array( 'not 0', '1' ),
+ array( '4 < 5', '1' ),
+ array( '-5 < 2', '1' ),
+ array( '-2 <= -2', '1' ),
+ array( '4 > 3', '1' ),
+ array( '4 > -3', '1' ),
+ array( '5 >= 2', '1' ),
+ array( '2 >= 2', '1' ),
+ array( '1 != 2', '1' ),
+ array( '-4 * -4 = 4 * 4', '1' ),
+ array( 'not (1 != 1)', '1' ),
+ array( '1 + 1', '2' ),
+ array( '-1 + 1', '0' ),
+ array( '+1 + 1', '2' ),
+ array( '4 * 4', '16' ),
+ array( '(1/3) * 3', '1' ),
+ array( '3 / 1.5', '2' ),
+ array( '3 / 0.2', '15' ),
+ array( '3 / ( 2.0 * 0.1 )', '15' ),
+ array( '3 / ( 2.0 / 10 )', '15' ),
+ array( '3 / (- 0.2 )', '-15' ),
+ array( '3 / abs( 0.2 )', '15' ),
+ array( '3 mod 2', '1' ),
+ array( '1e4', '10000' ),
+ array( '1e-2', '0.01' ),
+ array( '4.0 round 0', '4' ),
+ array( 'ceil 4', '4' ),
+ array( 'floor 4', '4' ),
+ array( '4.5 round 0', '5' ),
+ array( '4.2 round 0', '4' ),
+ array( '-4.2 round 0', '-4' ),
+ array( '-4.5 round 0', '-5' ),
+ array( '-2.0 round 0', '-2' ),
+ array( 'ceil -3', '-3' ),
+ array( 'floor -6.0', '-6' ),
+ array( 'ceil 4.2', '5' ),
+ array( 'ceil -4.5', '-4' ),
+ array( 'floor -4.5', '-5' ),
+ array( 'abs(-2)', '2' ),
+ array( 'ln(exp(1))', '1' ),
+ array( 'trunc(4.5)', '4' ),
+ array( 'trunc(-4.5)', '-4' ),
+ array( '123 fmod (2^64-1)', '123' ),
+ array( '5.7 mod 1.3', '0' ),
+ array( '5.7 fmod 1.3', '0.5' ),
+ );
+ }
+}
+
diff --git a/extensions/PdfHandler/.gitreview b/extensions/PdfHandler/.gitreview
new file mode 100644
index 00000000..f5eca40e
--- /dev/null
+++ b/extensions/PdfHandler/.gitreview
@@ -0,0 +1,5 @@
+[gerrit]
+host=gerrit.wikimedia.org
+port=29418
+project=mediawiki/extensions/PdfHandler.git
+defaultbranch=master
diff --git a/extensions/PdfHandler/PdfHandler_body.php b/extensions/PdfHandler/PdfHandler_body.php
index 8fa6719b..73ce1b58 100644
--- a/extensions/PdfHandler/PdfHandler_body.php
+++ b/extensions/PdfHandler/PdfHandler_body.php
@@ -315,7 +315,7 @@ class PdfHandler extends ImageHandler {
*/
function pageCount( $image ) {
$data = $this->getMetaArray( $image );
- if ( !$data || !isset( $data['Pages'] ) ) {
+ if ( !$data ) {
return false;
}
return intval( $data['Pages'] );
diff --git a/extensions/Poem/.gitreview b/extensions/Poem/.gitreview
new file mode 100644
index 00000000..aac78b2b
--- /dev/null
+++ b/extensions/Poem/.gitreview
@@ -0,0 +1,5 @@
+[gerrit]
+host=gerrit.wikimedia.org
+port=29418
+project=mediawiki/extensions/Poem.git
+defaultbranch=master
diff --git a/extensions/Renameuser/.gitreview b/extensions/Renameuser/.gitreview
new file mode 100644
index 00000000..0d757141
--- /dev/null
+++ b/extensions/Renameuser/.gitreview
@@ -0,0 +1,5 @@
+[gerrit]
+host=gerrit.wikimedia.org
+port=29418
+project=mediawiki/extensions/Renameuser.git
+defaultbranch=master
diff --git a/extensions/SpamBlacklist/.gitreview b/extensions/SpamBlacklist/.gitreview
new file mode 100644
index 00000000..d74ae8f9
--- /dev/null
+++ b/extensions/SpamBlacklist/.gitreview
@@ -0,0 +1,5 @@
+[gerrit]
+host=gerrit.wikimedia.org
+port=29418
+project=mediawiki/extensions/SpamBlacklist.git
+defaultbranch=master
diff --git a/extensions/SyntaxHighlight_GeSHi/.gitreview b/extensions/SyntaxHighlight_GeSHi/.gitreview
new file mode 100644
index 00000000..cb9e4b44
--- /dev/null
+++ b/extensions/SyntaxHighlight_GeSHi/.gitreview
@@ -0,0 +1,5 @@
+[gerrit]
+host=gerrit.wikimedia.org
+port=29418
+project=mediawiki/extensions/SyntaxHighlight_GeSHi.git
+defaultbranch=master
diff --git a/extensions/SyntaxHighlight_GeSHi/geshi/contrib/aliased.php b/extensions/SyntaxHighlight_GeSHi/geshi/contrib/aliased.php
deleted file mode 100644
index cee31289..00000000
--- a/extensions/SyntaxHighlight_GeSHi/geshi/contrib/aliased.php
+++ /dev/null
@@ -1,123 +0,0 @@
-
- * @version $Id: aliased.php 2533 2012-08-15 18:49:04Z benbe $
- */
-
-// Your config here
-define("SOURCE_ROOT", "/var/www/your/source/root/");
-
-// Assume you've put geshi in the include_path already
-require_once("geshi.php");
-
-// Get path info
-$path = SOURCE_ROOT.$_SERVER['PATH_INFO'];
-
-// Check for dickheads trying to use '../' to get to sensitive areas
-$base_path_len = strlen(SOURCE_ROOT);
-$real_path = realpath($path);
-if(strncmp($real_path, SOURCE_ROOT, $base_path_len)) {
- exit("Access outside acceptable path.");
-}
-
-// Check file exists
-if(!file_exists($path)) {
- exit("File not found ($path).");
-}
-
-// Prepare GeSHi instance
-$geshi = new GeSHi();
-$geshi->set_language('text');
-$geshi->load_from_file($path);
-$geshi->set_header_type(GESHI_HEADER_PRE);
-$geshi->enable_classes();
-$geshi->enable_line_numbers(GESHI_FANCY_LINE_NUMBERS, 10);
-$geshi->set_overall_style('color: #000066; border: 1px solid #d0d0d0; background-color: #f0f0f0;', true);
-$geshi->set_line_style('font: normal normal 95% \'Courier New\', Courier, monospace; color: #003030;', 'font-weight: bold; color: #006060;', true);
-$geshi->set_code_style('color: #000020;', 'color: #000020;');
-$geshi->set_link_styles(GESHI_LINK, 'color: #000060;');
-$geshi->set_link_styles(GESHI_HOVER, 'background-color: #f0f000;');
-$geshi->set_header_content('Source code viewer - ' . $path . ' - ' . $geshi->get_language_name());
-$geshi->set_header_content_style('font-family: Verdana, Arial, sans-serif; color: #808080; font-size: 70%; font-weight: bold; background-color: #f0f0ff; border-bottom: 1px solid #d0d0d0; padding: 2px;');
-$geshi->set_footer_content('Parsed in