From: Siebrand Mazeland Date: Thu, 24 Apr 2014 17:52:09 +0000 (+0200) Subject: Pass phpcs-strict on some test files (9/11) X-Git-Tag: 1.31.0-rc.0~16022^2 X-Git-Url: https://git.heureux-cyclage.org/?a=commitdiff_plain;h=5a16395d8e5c7f3ca4c18d173951657ef5ef7b54;p=lhc%2Fweb%2Fwiklou.git Pass phpcs-strict on some test files (9/11) Change-Id: I69f17bf2af45f03274fdb38853184880e46c3514 --- diff --git a/tests/phpunit/includes/media/JpegTest.php b/tests/phpunit/includes/media/JpegTest.php index 1b28de1dd0..b2611371f8 100644 --- a/tests/phpunit/includes/media/JpegTest.php +++ b/tests/phpunit/includes/media/JpegTest.php @@ -37,7 +37,9 @@ class JpegTest extends MediaWikiTestCase { public function testJpegMetadataExtraction() { $file = $this->dataFile( 'test.jpg', 'image/jpeg' ); $res = $this->handler->getMetadata( $file, $this->filePath . 'test.jpg' ); + // @codingStandardsIgnoreStart Ignore Generic.Files.LineLength.TooLong $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;}'; + // @codingStandardsIgnoreEnd // Unserialize in case serialization format ever changes. $this->assertEquals( unserialize( $expected ), unserialize( $res ) ); diff --git a/tests/phpunit/includes/media/PNGTest.php b/tests/phpunit/includes/media/PNGTest.php index aa73e2d661..59d40de3f1 100644 --- a/tests/phpunit/includes/media/PNGTest.php +++ b/tests/phpunit/includes/media/PNGTest.php @@ -92,7 +92,9 @@ class PNGHandlerTest extends MediaWikiTestCase { array( '', PNGHandler::METADATA_BAD ), array( null, PNGHandler::METADATA_BAD ), array( 'Something invalid!', PNGHandler::METADATA_BAD ), + // @codingStandardsIgnoreStart Ignore Generic.Files.LineLength.TooLong 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 ), + // @codingStandardsIgnoreEnd ); } @@ -111,8 +113,10 @@ class PNGHandlerTest extends MediaWikiTestCase { public static function provideGetMetadata() { return array( + // @codingStandardsIgnoreStart Ignore Generic.Files.LineLength.TooLong 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;}}' ), + // @codingStandardsIgnoreEnd ); } diff --git a/tests/phpunit/includes/media/SVGMetadataExtractorTest.php b/tests/phpunit/includes/media/SVGMetadataExtractorTest.php index ec7b0c90d6..fa63fa64f2 100644 --- a/tests/phpunit/includes/media/SVGMetadataExtractorTest.php +++ b/tests/phpunit/includes/media/SVGMetadataExtractorTest.php @@ -121,12 +121,15 @@ class SVGMetadataExtractorTest extends MediaWikiTestCase { public static function provideSvgFilesWithXMLMetadata() { $base = __DIR__ . '/../../data/media'; + // @codingStandardsIgnoreStart Ignore Generic.Files.LineLength.TooLong $metadata = ' image/svg+xml '; + // @codingStandardsIgnoreEnd + $metadata = str_replace( "\r", '', $metadata ); // Windows compat return array( array( diff --git a/tests/phpunit/includes/media/SVGTest.php b/tests/phpunit/includes/media/SVGTest.php index 97e6c43f91..8a3d527c84 100644 --- a/tests/phpunit/includes/media/SVGTest.php +++ b/tests/phpunit/includes/media/SVGTest.php @@ -40,7 +40,8 @@ class SvgTest extends MediaWikiTestCase { return array( array( 'Tux.svg', array( 'ObjectName' => 'Tux', - 'ImageDescription' => 'For more information see: http://commons.wikimedia.org/wiki/Image:Tux.svg', + 'ImageDescription' => + 'For more information see: http://commons.wikimedia.org/wiki/Image:Tux.svg', ) ), array( 'Wikimedia-logo.svg', array() ) ); diff --git a/tests/phpunit/includes/media/TiffTest.php b/tests/phpunit/includes/media/TiffTest.php index ca97698364..26d7204004 100644 --- a/tests/phpunit/includes/media/TiffTest.php +++ b/tests/phpunit/includes/media/TiffTest.php @@ -29,7 +29,11 @@ class TiffTest extends MediaWikiTestCase { */ public function testTiffMetadataExtraction() { $res = $this->handler->getMetadata( null, $this->filePath . 'test.tiff' ); + + // @codingStandardsIgnoreStart Ignore Generic.Files.LineLength.TooLong $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;}'; + // @codingStandardsIgnoreEnd + // 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/normal/CleanUpTest.php b/tests/phpunit/includes/normal/CleanUpTest.php index a736234f06..dff31c1e5a 100644 --- a/tests/phpunit/includes/normal/CleanUpTest.php +++ b/tests/phpunit/includes/normal/CleanUpTest.php @@ -89,7 +89,9 @@ class CleanUpTest extends MediaWikiTestCase { ( $i > UNICODE_SURROGATE_LAST && $i < 0xfffe ) || ( $i > 0xffff && $i <= UNICODE_MAX ) ) { - if ( isset( UtfNormal::$utfCanonicalComp[$char] ) || isset( UtfNormal::$utfCanonicalDecomp[$char] ) ) { + if ( isset( UtfNormal::$utfCanonicalComp[$char] ) + || isset( UtfNormal::$utfCanonicalDecomp[$char] ) + ) { $comp = UtfNormal::NFC( $char ); $this->assertEquals( bin2hex( $comp ), @@ -243,12 +245,14 @@ class CleanUpTest extends MediaWikiTestCase { } } elseif ( $first > 0xc1 && $first < 0xe0 && $second < 0xc0 ) { $this->assertEquals( - bin2hex( UtfNormal::NFC( $head . chr( $first ) . chr( $second ) ) . UTF8_REPLACEMENT . $tail ), + 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( $head . UTF8_REPLACEMENT . + UtfNormal::NFC( chr( $second ) . chr( $third ) . $tail ) ), bin2hex( $clean ), "Broken head + valid 2-byte $x" ); } elseif ( ( $first > 0xfd || $second > 0xfd ) && diff --git a/tests/phpunit/includes/objectcache/BagOStuffTest.php b/tests/phpunit/includes/objectcache/BagOStuffTest.php index 1670823d35..1972bb50a4 100644 --- a/tests/phpunit/includes/objectcache/BagOStuffTest.php +++ b/tests/phpunit/includes/objectcache/BagOStuffTest.php @@ -138,7 +138,10 @@ class BagOStuffTest extends MediaWikiTestCase { $this->cache->add( $key1, $value1 ); $this->cache->add( $key2, $value2 ); - $this->assertEquals( $this->cache->getMulti( array( $key1, $key2 ) ), array( $key1 => $value1, $key2 => $value2 ) ); + $this->assertEquals( + $this->cache->getMulti( array( $key1, $key2 ) ), + array( $key1 => $value1, $key2 => $value2 ) + ); // cleanup $this->cache->delete( $key1 ); diff --git a/tests/phpunit/includes/parser/MagicVariableTest.php b/tests/phpunit/includes/parser/MagicVariableTest.php index 2ad2735da8..b81c973ae6 100644 --- a/tests/phpunit/includes/parser/MagicVariableTest.php +++ b/tests/phpunit/includes/parser/MagicVariableTest.php @@ -48,7 +48,9 @@ class MagicVariableTest extends MediaWikiTestCase { # 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) + # Else it needs a db connection just to check if it's a redirect + # (when deciding the page language). + $title->mRedirect = false; $this->testParser->setTitle( $title ); } diff --git a/tests/phpunit/includes/parser/ParserMethodsTest.php b/tests/phpunit/includes/parser/ParserMethodsTest.php index e5c5cb2144..229eeb44bc 100644 --- a/tests/phpunit/includes/parser/ParserMethodsTest.php +++ b/tests/phpunit/includes/parser/ParserMethodsTest.php @@ -91,5 +91,6 @@ class ParserMethodsTest extends MediaWikiLangTestCase { ), ), $out->getSections(), 'getSections() with proper value when

is used' ); } - //@Todo Add tests for cleanSig() / cleanSigInSig(), getSection(), replaceSection(), getPreloadText() + // @todo Add tests for cleanSig() / cleanSigInSig(), getSection(), + // replaceSection(), getPreloadText() } diff --git a/tests/phpunit/includes/parser/PreprocessorTest.php b/tests/phpunit/includes/parser/PreprocessorTest.php index cfb3f72e7a..345fd0a524 100644 --- a/tests/phpunit/includes/parser/PreprocessorTest.php +++ b/tests/phpunit/includes/parser/PreprocessorTest.php @@ -16,7 +16,9 @@ class PreprocessorTest extends MediaWikiTestCase { global $wgParserConf, $wgContLang; parent::setUp(); $this->mOptions = ParserOptions::newFromUserAndLang( new User, $wgContLang ); - $name = isset( $wgParserConf['preprocessorClass'] ) ? $wgParserConf['preprocessorClass'] : 'Preprocessor_DOM'; + $name = isset( $wgParserConf['preprocessorClass'] ) + ? $wgParserConf['preprocessorClass'] + : 'Preprocessor_DOM'; $this->mPreprocessor = new $name( $this ); } @@ -26,6 +28,7 @@ class PreprocessorTest extends MediaWikiTestCase { } public static function provideCases() { + // @codingStandardsIgnoreStart Ignore Generic.Files.LineLength.TooLong return array( array( "Foo", "Foo" ), array( "", "<!-- Foo -->" ), @@ -113,6 +116,7 @@ class PreprocessorTest extends MediaWikiTestCase { array( "{{Foo|} Bar=}}", "" ), /* array( file_get_contents( __DIR__ . '/QuoteQuran.txt' ), file_get_contents( __DIR__ . '/QuoteQuranExpanded.txt' ) ), */ ); + // @codingStandardsIgnoreEnd } /** @@ -157,6 +161,7 @@ class PreprocessorTest extends MediaWikiTestCase { * These are more complex test cases taken out of wiki articles. */ public static function provideFiles() { + // @codingStandardsIgnoreStart Ignore Generic.Files.LineLength.TooLong 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 @@ -164,6 +169,7 @@ class PreprocessorTest extends MediaWikiTestCase { array( "Fundraising" ), # http://tl.wiktionary.org/w/index.php?title=MediaWiki:Sitenotice&oldid=5716 GFDL + CC BY-SA, copied there by Sky Harbor. array( "NestedTemplates" ), # bug 27936 ); + // @codingStandardsIgnoreEnd } /** @@ -190,6 +196,7 @@ class PreprocessorTest extends MediaWikiTestCase { * Tests from Bug 28642 · https://bugzilla.wikimedia.org/28642 */ public static function provideHeadings() { + // @codingStandardsIgnoreStart Ignore Generic.Files.LineLength.TooLong return array( /* These should become headings: */ array( "== h ==", "== h ==<!--c1-->" ), array( "== h == ", "== h == <!--c1-->" ), @@ -227,6 +234,7 @@ class PreprocessorTest extends MediaWikiTestCase { array( "== h == x ", "== h ==<!--c1--> x <!--c2--><!--c3--> " ), array( "== h == x ", "== h ==<!--c1--><!--c2--><!--c3--> x " ), ); + // @codingStandardsIgnoreEnd } /**