Cleanup tests/includes/media
authoraddshore <addshorewiki@gmail.com>
Wed, 23 Oct 2013 22:12:39 +0000 (23:12 +0100)
committerHashar <hashar@free.fr>
Thu, 24 Oct 2013 08:12:42 +0000 (08:12 +0000)
- Adds @covers tags
- fixes comments
- fixes scope
- adds @todos
- split files per class

Change-Id: Id5aaa20769725a96f22fb838d376697c250874a5

20 files changed:
tests/TestsAutoLoader.php
tests/phpunit/includes/media/BitmapMetadataHandlerTest.php
tests/phpunit/includes/media/BitmapScalingTest.php
tests/phpunit/includes/media/ExifBitmapTest.php
tests/phpunit/includes/media/ExifRotationTest.php
tests/phpunit/includes/media/ExifTest.php
tests/phpunit/includes/media/FakeDimensionFile.php [new file with mode: 0644]
tests/phpunit/includes/media/FormatMetadataTest.php
tests/phpunit/includes/media/GIFMetadataExtractorTest.php
tests/phpunit/includes/media/GIFTest.php
tests/phpunit/includes/media/IPTCTest.php
tests/phpunit/includes/media/JpegMetadataExtractorTest.php
tests/phpunit/includes/media/JpegTest.php
tests/phpunit/includes/media/MediaHandlerTest.php
tests/phpunit/includes/media/PNGMetadataExtractorTest.php
tests/phpunit/includes/media/PNGTest.php
tests/phpunit/includes/media/SVGMetadataExtractorTest.php
tests/phpunit/includes/media/TiffTest.php
tests/phpunit/includes/media/XMPTest.php
tests/phpunit/includes/media/XMPValidateTest.php

index cd9a93e..00ce13c 100644 (file)
@@ -78,6 +78,9 @@ $wgAutoloadClasses += array(
        # tests/phpunit/includes/libs
        'GenericArrayObjectTest' => "$testDir/phpunit/includes/libs/GenericArrayObjectTest.php",
 
+       # tests/phpunit/media
+       'FakeDimensionFile' => "$testDir/phpunit/includes/media/FakeDimensionFile.php",
+
        # tests/phpunit/includes/site
        'SiteTest' => "$testDir/phpunit/includes/site/SiteTest.php",
        'TestSites' => "$testDir/phpunit/includes/site/TestSites.php",
index 43792c1..a0e63a8 100644 (file)
@@ -16,6 +16,7 @@ class BitmapMetadataHandlerTest extends MediaWikiTestCase {
         * Basically the file has IPTC and XMP metadata, the
         * IPTC should override the XMP, except for the multilingual
         * translation (to en) where XMP should win.
+        * @covers BitmapMetadataHandler::Jpeg
         */
        public function testMultilingualCascade() {
                if ( !extension_loaded( 'exif' ) ) {
@@ -48,6 +49,7 @@ class BitmapMetadataHandlerTest extends MediaWikiTestCase {
         *
         * There's more extensive tests of comment extraction in
         * JpegMetadataExtractorTests.php
+        * @covers BitmapMetadataHandler::Jpeg
         */
        public function testJpegComment() {
                $meta = BitmapMetadataHandler::Jpeg( $this->filePath .
@@ -60,6 +62,7 @@ class BitmapMetadataHandlerTest extends MediaWikiTestCase {
        /**
         * Make sure a bad iptc block doesn't stop the other metadata
         * from being extracted.
+        * @covers BitmapMetadataHandler::Jpeg
         */
        public function testBadIPTC() {
                $meta = BitmapMetadataHandler::Jpeg( $this->filePath .
@@ -67,6 +70,9 @@ class BitmapMetadataHandlerTest extends MediaWikiTestCase {
                $this->assertEquals( 'Created with GIMP', $meta['JPEGFileComment'][0] );
        }
 
+       /**
+        * @covers BitmapMetadataHandler::Jpeg
+        */
        public function testIPTCDates() {
                $meta = BitmapMetadataHandler::Jpeg( $this->filePath .
                        'iptc-timetest.jpg' );
@@ -78,6 +84,7 @@ class BitmapMetadataHandlerTest extends MediaWikiTestCase {
        /**
         * File has an invalid time (+ one valid but really weird time)
         * that shouldn't be included
+        * @covers BitmapMetadataHandler::Jpeg
         */
        public function testIPTCDatesInvalid() {
                $meta = BitmapMetadataHandler::Jpeg( $this->filePath .
@@ -91,6 +98,8 @@ class BitmapMetadataHandlerTest extends MediaWikiTestCase {
         * XMP data should take priority over iptc data
         * when hash has been updated, but not when
         * the hash is wrong.
+        * @covers BitmapMetadataHandler::addMetadata
+        * @covers BitmapMetadataHandler::getMetadataArray
         */
        public function testMerging() {
                $merger = new BitmapMetadataHandler();
@@ -114,6 +123,9 @@ class BitmapMetadataHandlerTest extends MediaWikiTestCase {
                $this->assertEquals( $expected, $actual );
        }
 
+       /**
+        * @covers BitmapMetadataHandler::png
+        */
        public function testPNGXMP() {
                if ( !extension_loaded( 'xml' ) ) {
                        $this->markTestSkipped( "This test needs the xml extension." );
@@ -134,6 +146,9 @@ class BitmapMetadataHandlerTest extends MediaWikiTestCase {
                $this->assertEquals( $expected, $result );
        }
 
+       /**
+        * @covers BitmapMetadataHandler::png
+        */
        public function testPNGNative() {
                $handler = new BitmapMetadataHandler();
                $result = $handler->png( $this->filePath . 'Png-native-test.png' );
@@ -141,6 +156,9 @@ class BitmapMetadataHandlerTest extends MediaWikiTestCase {
                $this->assertEquals( $expected, $result['metadata']['Identifier']['x-default'] );
        }
 
+       /**
+        * @covers BitmapMetadataHandler::getTiffByteOrder
+        */
        public function testTiffByteOrder() {
                $handler = new BitmapMetadataHandler();
                $res = $handler->getTiffByteOrder( $this->filePath . 'test.tiff' );
index c4706bf..9395b66 100644 (file)
@@ -13,8 +13,9 @@ class BitmapScalingTest extends MediaWikiTestCase {
 
        /**
         * @dataProvider provideNormaliseParams
+        * @covers BitmapHandler::normaliseParams
         */
-       function testNormaliseParams( $fileDimensions, $expectedParams, $params, $msg ) {
+       public function testNormaliseParams( $fileDimensions, $expectedParams, $params, $msg ) {
                $file = new FakeDimensionFile( $fileDimensions );
                $handler = new BitmapHandler;
                $valid = $handler->normaliseParams( $file, $params );
@@ -102,7 +103,10 @@ class BitmapScalingTest extends MediaWikiTestCase {
                );
        }
 
-       function testTooBigImage() {
+       /**
+        * @covers BitmapHandler::doTransform
+        */
+       public function testTooBigImage() {
                $file = new FakeDimensionFile( array( 4000, 4000 ) );
                $handler = new BitmapHandler;
                $params = array( 'width' => '3700' ); // Still bigger than max size.
@@ -110,7 +114,10 @@ class BitmapScalingTest extends MediaWikiTestCase {
                        get_class( $handler->doTransform( $file, 'dummy path', '', $params ) ) );
        }
 
-       function testTooBigMustRenderImage() {
+       /**
+        * @covers BitmapHandler::doTransform
+        */
+       public function testTooBigMustRenderImage() {
                $file = new FakeDimensionFile( array( 4000, 4000 ) );
                $file->mustRender = true;
                $handler = new BitmapHandler;
@@ -119,36 +126,12 @@ class BitmapScalingTest extends MediaWikiTestCase {
                        get_class( $handler->doTransform( $file, 'dummy path', '', $params ) ) );
        }
 
-       function testImageArea() {
+       /**
+        * @covers BitmapHandler::getImageArea
+        */
+       public function testImageArea() {
                $file = new FakeDimensionFile( array( 7, 9 ) );
                $handler = new BitmapHandler;
                $this->assertEquals( 63, $handler->getImageArea( $file ) );
        }
 }
-
-class FakeDimensionFile extends File {
-       public $mustRender = false;
-
-       public function __construct( $dimensions ) {
-               parent::__construct( Title::makeTitle( NS_FILE, 'Test' ),
-                       new NullRepo( null ) );
-
-               $this->dimensions = $dimensions;
-       }
-
-       public function getWidth( $page = 1 ) {
-               return $this->dimensions[0];
-       }
-
-       public function getHeight( $page = 1 ) {
-               return $this->dimensions[1];
-       }
-
-       public function mustRender() {
-               return $this->mustRender;
-       }
-
-       public function getPath() {
-               return '';
-       }
-}
index 532182c..a2e0eb6 100644 (file)
@@ -2,6 +2,11 @@
 
 class ExifBitmapTest extends MediaWikiTestCase {
 
+       /**
+        * @var ExifBitmapHandler
+        */
+       protected $handler;
+
        protected function setUp() {
                parent::setUp();
                if ( !extension_loaded( 'exif' ) ) {
@@ -14,42 +19,62 @@ class ExifBitmapTest extends MediaWikiTestCase {
 
        }
 
+       /**
+        * @covers ExifBitmapHandler::isMetadataValid
+        */
        public function testIsOldBroken() {
                $res = $this->handler->isMetadataValid( null, ExifBitmapHandler::OLD_BROKEN_FILE );
                $this->assertEquals( ExifBitmapHandler::METADATA_COMPATIBLE, $res );
        }
 
+       /**
+        * @covers ExifBitmapHandler::isMetadataValid
+        */
        public function testIsBrokenFile() {
                $res = $this->handler->isMetadataValid( null, ExifBitmapHandler::BROKEN_FILE );
                $this->assertEquals( ExifBitmapHandler::METADATA_GOOD, $res );
        }
 
+       /**
+        * @covers ExifBitmapHandler::isMetadataValid
+        */
        public function testIsInvalid() {
                $res = $this->handler->isMetadataValid( null, 'Something Invalid Here.' );
                $this->assertEquals( ExifBitmapHandler::METADATA_BAD, $res );
        }
 
+       /**
+        * @covers ExifBitmapHandler::isMetadataValid
+        */
        public function testGoodMetadata() {
                $meta = '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;}';
                $res = $this->handler->isMetadataValid( null, $meta );
                $this->assertEquals( ExifBitmapHandler::METADATA_GOOD, $res );
        }
 
+       /**
+        * @covers ExifBitmapHandler::isMetadataValid
+        */
        public function testIsOldGood() {
                $meta = '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:1;}';
                $res = $this->handler->isMetadataValid( null, $meta );
                $this->assertEquals( ExifBitmapHandler::METADATA_COMPATIBLE, $res );
        }
 
-       // Handle metadata from paged tiff handler (gotten via instant commons)
-       // gracefully.
+       /**
+        * Handle metadata from paged tiff handler (gotten via instant commons) gracefully.
+        * @covers ExifBitmapHandler::isMetadataValid
+        */
        public function testPagedTiffHandledGracefully() {
                $meta = 'a:6:{s:9:"page_data";a:1:{i:1;a:5:{s:5:"width";i:643;s:6:"height";i:448;s:5:"alpha";s:4:"true";s:4:"page";i:1;s:6:"pixels";i:288064;}}s:10:"page_count";i:1;s:10:"first_page";i:1;s:9:"last_page";i:1;s:4:"exif";a:9:{s:10:"ImageWidth";i:643;s:11:"ImageLength";i:448;s:11:"Compression";i:5;s:25:"PhotometricInterpretation";i:2;s:11:"Orientation";i:1;s:15:"SamplesPerPixel";i:4;s:12:"RowsPerStrip";i:50;s:19:"PlanarConfiguration";i:1;s:22:"MEDIAWIKI_EXIF_VERSION";i:1;}s:21:"TIFF_METADATA_VERSION";s:3:"1.4";}';
                $res = $this->handler->isMetadataValid( null, $meta );
                $this->assertEquals( ExifBitmapHandler::METADATA_BAD, $res );
        }
 
-       function testConvertMetadataLatest() {
+       /**
+        * @covers ExifBitmapHandler::convertMetadataVersion
+        */
+       public function testConvertMetadataLatest() {
                $metadata = array(
                        'foo' => array( 'First', 'Second', '_type' => 'ol' ),
                        'MEDIAWIKI_EXIF_VERSION' => 2
@@ -58,7 +83,10 @@ class ExifBitmapTest extends MediaWikiTestCase {
                $this->assertEquals( $metadata, $res );
        }
 
-       function testConvertMetadataToOld() {
+       /**
+        * @covers ExifBitmapHandler::convertMetadataVersion
+        */
+       public function testConvertMetadataToOld() {
                $metadata = array(
                        'foo' => array( 'First', 'Second', '_type' => 'ol' ),
                        'bar' => array( 'First', 'Second', '_type' => 'ul' ),
@@ -77,7 +105,10 @@ class ExifBitmapTest extends MediaWikiTestCase {
                $this->assertEquals( $expected, $res );
        }
 
-       function testConvertMetadataSoftware() {
+       /**
+        * @covers ExifBitmapHandler::convertMetadataVersion
+        */
+       public function testConvertMetadataSoftware() {
                $metadata = array(
                        'Software' => array( array( 'GIMP', '1.1' ) ),
                        'MEDIAWIKI_EXIF_VERSION' => 2,
@@ -90,7 +121,10 @@ class ExifBitmapTest extends MediaWikiTestCase {
                $this->assertEquals( $expected, $res );
        }
 
-       function testConvertMetadataSoftwareNormal() {
+       /**
+        * @covers ExifBitmapHandler::convertMetadataVersion
+        */
+       public function testConvertMetadataSoftwareNormal() {
                $metadata = array(
                        'Software' => array( "GIMP 1.2", "vim" ),
                        'MEDIAWIKI_EXIF_VERSION' => 2,
index c16de8b..64276d9 100644 (file)
@@ -3,6 +3,8 @@
  * Tests related to auto rotation.
  *
  * @group medium
+ *
+ * @todo covers tags
  */
 class ExifRotationTest extends MediaWikiTestCase {
 
@@ -34,10 +36,9 @@ class ExifRotationTest extends MediaWikiTestCase {
        }
 
        /**
-        *
         * @dataProvider provideFiles
         */
-       function testMetadata( $name, $type, $info ) {
+       public function testMetadata( $name, $type, $info ) {
                if ( !BitmapHandler::canRotate() ) {
                        $this->markTestSkipped( "This test needs a rasterizer that can auto-rotate." );
                }
@@ -50,7 +51,7 @@ class ExifRotationTest extends MediaWikiTestCase {
         *
         * @dataProvider provideFiles
         */
-       function testRotationRendering( $name, $type, $info, $thumbs ) {
+       public function testRotationRendering( $name, $type, $info, $thumbs ) {
                if ( !BitmapHandler::canRotate() ) {
                        $this->markTestSkipped( "This test needs a rasterizer that can auto-rotate." );
                }
@@ -129,7 +130,7 @@ class ExifRotationTest extends MediaWikiTestCase {
         * Same as before, but with auto-rotation disabled.
         * @dataProvider provideFilesNoAutoRotate
         */
-       function testMetadataNoAutoRotate( $name, $type, $info ) {
+       public function testMetadataNoAutoRotate( $name, $type, $info ) {
                $this->setMwGlobals( 'wgEnableAutoRotation', false );
 
                $file = $this->dataFile( $name, $type );
@@ -141,7 +142,7 @@ class ExifRotationTest extends MediaWikiTestCase {
         *
         * @dataProvider provideFilesNoAutoRotate
         */
-       function testRotationRenderingNoAutoRotate( $name, $type, $info, $thumbs ) {
+       public function testRotationRenderingNoAutoRotate( $name, $type, $info, $thumbs ) {
                $this->setMwGlobals( 'wgEnableAutoRotation', false );
 
                foreach ( $thumbs as $size => $out ) {
@@ -216,7 +217,7 @@ class ExifRotationTest extends MediaWikiTestCase {
        /**
         * @dataProvider provideBitmapExtractPreRotationDimensions
         */
-       function testBitmapExtractPreRotationDimensions( $rotation, $expected ) {
+       public function testBitmapExtractPreRotationDimensions( $rotation, $expected ) {
                $result = $this->handler->extractPreRotationDimensions( array(
                        'physicalWidth' => self::TEST_WIDTH,
                        'physicalHeight' => self::TEST_HEIGHT,
index b84ed56..dea36b0 100644 (file)
@@ -1,6 +1,9 @@
 <?php
 class ExifTest extends MediaWikiTestCase {
 
+       /** @var string */
+       protected $mediaPath;
+
        protected function setUp() {
                parent::setUp();
                if ( !extension_loaded( 'exif' ) ) {
diff --git a/tests/phpunit/includes/media/FakeDimensionFile.php b/tests/phpunit/includes/media/FakeDimensionFile.php
new file mode 100644 (file)
index 0000000..7926000
--- /dev/null
@@ -0,0 +1,28 @@
+<?php
+
+class FakeDimensionFile extends File {
+       public $mustRender = false;
+
+       public function __construct( $dimensions ) {
+               parent::__construct( Title::makeTitle( NS_FILE, 'Test' ),
+                       new NullRepo( null ) );
+
+               $this->dimensions = $dimensions;
+       }
+
+       public function getWidth( $page = 1 ) {
+               return $this->dimensions[0];
+       }
+
+       public function getHeight( $page = 1 ) {
+               return $this->dimensions[1];
+       }
+
+       public function mustRender() {
+               return $this->mustRender;
+       }
+
+       public function getPath() {
+               return '';
+       }
+}
\ No newline at end of file
index bee0906..a073e4c 100644 (file)
@@ -1,6 +1,15 @@
 <?php
+
+/**
+ * @todo covers tags
+ */
 class FormatMetadataTest extends MediaWikiTestCase {
 
+       /** @var FSFileBackend */
+       protected $backend;
+       /** @var FSRepo */
+       protected $repo;
+
        protected function setUp() {
                parent::setUp();
 
index 86cf346..9e3f924 100644 (file)
@@ -12,6 +12,7 @@ class GIFMetadataExtractorTest extends MediaWikiTestCase {
         * @param $filename String
         * @param $expected Array The extracted metadata.
         * @dataProvider provideGetMetadata
+        * @covers GIFMetadataExtractor::getMetadata
         */
        public function testGetMetadata( $filename, $expected ) {
                $actual = GIFMetadataExtractor::getMetadata( $this->mediaPath . $filename );
index 7ea6b7e..c8e729c 100644 (file)
@@ -1,6 +1,15 @@
 <?php
 class GIFHandlerTest extends MediaWikiTestCase {
 
+       /** @var FSFileBackend */
+       protected $backend;
+       /** @var GIFHandler */
+       protected $handler;
+       /** @var FSRepo */
+       protected $repo;
+       /** @var string */
+       protected $filePath;
+
        protected function setUp() {
                parent::setUp();
 
@@ -18,6 +27,9 @@ class GIFHandlerTest extends MediaWikiTestCase {
                $this->handler = new GIFHandler();
        }
 
+       /**
+        * @covers GIFHandler::getMetadata
+        */
        public function testInvalidFile() {
                $res = $this->handler->getMetadata( null, $this->filePath . '/README' );
                $this->assertEquals( GIFHandler::BROKEN_FILE, $res );
@@ -27,6 +39,7 @@ class GIFHandlerTest extends MediaWikiTestCase {
         * @param $filename String basename of the file to check
         * @param $expected boolean Expected result.
         * @dataProvider provideIsAnimated
+        * @covers GIFHandler::isAnimatedImage
         */
        public function testIsAnimanted( $filename, $expected ) {
                $file = $this->dataFile( $filename, 'image/gif' );
@@ -45,6 +58,7 @@ class GIFHandlerTest extends MediaWikiTestCase {
         * @param $filename String
         * @param $expected Integer Total image area
         * @dataProvider provideGetImageArea
+        * @covers GIFHandler::getImageArea
         */
        public function testGetImageArea( $filename, $expected ) {
                $file = $this->dataFile( $filename, 'image/gif' );
@@ -63,6 +77,7 @@ class GIFHandlerTest extends MediaWikiTestCase {
         * @param $metadata String Serialized metadata
         * @param $expected Integer One of the class constants of GIFHandler
         * @dataProvider provideIsMetadataValid
+        * @covers GIFHandler::isMetadataValid
         */
        public function testIsMetadataValid( $metadata, $expected ) {
                $actual = $this->handler->isMetadataValid( null, $metadata );
@@ -83,6 +98,7 @@ class GIFHandlerTest extends MediaWikiTestCase {
         * @param $filename String
         * @param $expected String Serialized array
         * @dataProvider provideGetMetadata
+        * @covers GIFHandler::getMetadata
         */
        public function testGetMetadata( $filename, $expected ) {
                $file = $this->dataFile( $filename, 'image/gif' );
index 81a58dd..81c1d28 100644 (file)
@@ -1,11 +1,19 @@
 <?php
+
 class IPTCTest extends MediaWikiTestCase {
+
+       /**
+        * @covers IPTC::getCharset
+        */
        public function testRecognizeUtf8() {
                // utf-8 is the only one used in practise.
                $res = IPTC::getCharset( "\x1b%G" );
                $this->assertEquals( 'UTF-8', $res );
        }
 
+       /**
+        * @covers IPTC::Parse
+        */
        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
@@ -15,17 +23,22 @@ class IPTCTest extends MediaWikiTestCase {
                $this->assertEquals( array( '¼' ), $res['Keywords'] );
        }
 
-       /* This one contains a sequence that's valid iso 8859-1 but not valid utf8 */
-       /* \xC3 = Ãƒ, \xB8 = Â¸  */
+       /**
+        * @covers IPTC::Parse
+        */
        public function testIPTCParseNoCharset88591b() {
+               /* This one contains a sequence that's valid iso 8859-1 but not valid utf8 */
+               /* \xC3 = Ãƒ, \xB8 = Â¸  */
                $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.
+       /**
+        * 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 Ã¸
+        * @covers IPTC::Parse
         */
        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"
@@ -34,13 +47,19 @@ class IPTCTest extends MediaWikiTestCase {
                $this->assertEquals( array( 'ø' ), $res['Keywords'] );
        }
 
+       /**
+        * @covers IPTC::Parse
+        */
        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
+       /**
+        * Testing something that has 2 values for keyword
+        * @covers IPTC::Parse
+        */
        public function testIPTCParseMulti() {
                $iptcData = /* identifier */ "Photoshop 3.0\08BIM\4\4"
                        /* length */ . "\0\0\0\0\0\x0D"
@@ -50,6 +69,9 @@ class IPTCTest extends MediaWikiTestCase {
                $this->assertEquals( array( '¼', '¼½' ), $res['Keywords'] );
        }
 
+       /**
+        * @covers IPTC::Parse
+        */
        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";
index cae7137..eafc8a2 100644 (file)
@@ -5,9 +5,12 @@
  * serve as a very good "test". (Adobe photoshop probably creates such files
  * but it costs money). The implementation of it currently in MediaWiki is based
  * solely on reading the standard, without any real world test files.
+ * @todo covers tags
  */
 class JpegMetadataExtractorTest extends MediaWikiTestCase {
 
+       protected $filePath;
+
        protected function setUp() {
                parent::setUp();
 
@@ -18,7 +21,7 @@ class JpegMetadataExtractorTest extends MediaWikiTestCase {
         * We also use this test to test padding bytes don't
         * screw stuff up
         *
-        * @param $file filename
+        * @param string $file filename
         *
         * @dataProvider provideUtf8Comment
         */
index 7775c41..9af4f1e 100644 (file)
@@ -1,4 +1,7 @@
 <?php
+/**
+ * @todo covers tags
+ */
 class JpegTest extends MediaWikiTestCase {
 
        protected function setUp() {
index 4e4c649..c28898b 100644 (file)
@@ -1,7 +1,12 @@
 <?php
 
 class MediaHandlerTest extends MediaWikiTestCase {
-       function testFitBoxWidth() {
+
+       /**
+        * @covers MediaHandler::fitBoxWidth
+        * @todo split into a dataprovider and test method
+        */
+       public function testFitBoxWidth() {
                $vals = array(
                        array(
                                'width' => 50,
index 58d791f..939f2cf 100644 (file)
@@ -1,4 +1,8 @@
 <?php
+
+/**
+ * @todo covers tags
+ */
 class PNGMetadataExtractorTest extends MediaWikiTestCase {
 
        protected function setUp() {
@@ -9,7 +13,7 @@ class PNGMetadataExtractorTest extends MediaWikiTestCase {
        /**
         * Tests zTXt tag (compressed textual metadata)
         */
-       function testPngNativetZtxt() {
+       public function testPngNativetZtxt() {
                $this->checkPHPExtension( 'zlib' );
 
                $meta = PNGMetadataExtractor::getMetadata( $this->filePath .
@@ -26,7 +30,7 @@ class PNGMetadataExtractorTest extends MediaWikiTestCase {
        /**
         * Test tEXt tag (Uncompressed textual metadata)
         */
-       function testPngNativeText() {
+       public function testPngNativeText() {
                $meta = PNGMetadataExtractor::getMetadata( $this->filePath .
                        'Png-native-test.png' );
                $expected = "Some long image desc";
@@ -43,7 +47,7 @@ class PNGMetadataExtractorTest extends MediaWikiTestCase {
         * tEXt tags must be encoded iso-8859-1 (vs iTXt which are utf-8)
         * Make sure non-ascii characters get converted properly
         */
-       function testPngNativeTextNonAscii() {
+       public function testPngNativeTextNonAscii() {
                $meta = PNGMetadataExtractor::getMetadata( $this->filePath .
                        'Png-native-test.png' );
 
@@ -65,7 +69,7 @@ class PNGMetadataExtractorTest extends MediaWikiTestCase {
         * actual resolution of the image is (aka in dots per meter).
         */
        /*
-       function testPngPhysTag() {
+       public function testPngPhysTag() {
                $meta = PNGMetadataExtractor::getMetadata( $this->filePath .
                        'Png-native-test.png' );
 
@@ -81,7 +85,7 @@ class PNGMetadataExtractorTest extends MediaWikiTestCase {
        /**
         * Given a normal static PNG, check the animation metadata returned.
         */
-       function testStaticPngAnimationMetadata() {
+       public function testStaticPngAnimationMetadata() {
                $meta = PNGMetadataExtractor::getMetadata( $this->filePath .
                        'Png-native-test.png' );
 
@@ -94,7 +98,7 @@ class PNGMetadataExtractorTest extends MediaWikiTestCase {
         * Given an animated APNG image file
         * check it gets animated metadata right.
         */
-       function testApngAnimationMetadata() {
+       public function testApngAnimationMetadata() {
                $meta = PNGMetadataExtractor::getMetadata( $this->filePath .
                        'Animated_PNG_example_bouncing_beach_ball.png' );
 
@@ -104,46 +108,46 @@ class PNGMetadataExtractorTest extends MediaWikiTestCase {
                $this->assertEquals( 1.5, $meta['duration'], '', 0.00001 );
        }
 
-       function testPngBitDepth8() {
+       public function testPngBitDepth8() {
                $meta = PNGMetadataExtractor::getMetadata( $this->filePath .
                        'Png-native-test.png' );
 
                $this->assertEquals( 8, $meta['bitDepth'] );
        }
 
-       function testPngBitDepth1() {
+       public function testPngBitDepth1() {
                $meta = PNGMetadataExtractor::getMetadata( $this->filePath .
                        '1bit-png.png' );
                $this->assertEquals( 1, $meta['bitDepth'] );
        }
 
 
-       function testPngIndexColour() {
+       public function testPngIndexColour() {
                $meta = PNGMetadataExtractor::getMetadata( $this->filePath .
                        'Png-native-test.png' );
 
                $this->assertEquals( 'index-coloured', $meta['colorType'] );
        }
 
-       function testPngRgbColour() {
+       public function testPngRgbColour() {
                $meta = PNGMetadataExtractor::getMetadata( $this->filePath .
                        'rgb-png.png' );
                $this->assertEquals( 'truecolour-alpha', $meta['colorType'] );
        }
 
-       function testPngRgbNoAlphaColour() {
+       public function testPngRgbNoAlphaColour() {
                $meta = PNGMetadataExtractor::getMetadata( $this->filePath .
                        'rgb-na-png.png' );
                $this->assertEquals( 'truecolour', $meta['colorType'] );
        }
 
-       function testPngGreyscaleColour() {
+       public function testPngGreyscaleColour() {
                $meta = PNGMetadataExtractor::getMetadata( $this->filePath .
                        'greyscale-png.png' );
                $this->assertEquals( 'greyscale-alpha', $meta['colorType'] );
        }
 
-       function testPngGreyscaleNoAlphaColour() {
+       public function testPngGreyscaleNoAlphaColour() {
                $meta = PNGMetadataExtractor::getMetadata( $this->filePath .
                        'greyscale-na-png.png' );
                $this->assertEquals( 'greyscale', $meta['colorType'] );
index 855780d..ad4c249 100644 (file)
@@ -1,6 +1,15 @@
 <?php
 class PNGHandlerTest extends MediaWikiTestCase {
 
+       /** @var PNGHandler */
+       protected $handler;
+       /** @var FSRepo */
+       protected $repo;
+       /** @var FSFileBackend */
+       protected $backend;
+       /** @var string */
+       protected $filePath;
+
        protected function setUp() {
                parent::setUp();
 
@@ -18,6 +27,9 @@ class PNGHandlerTest extends MediaWikiTestCase {
                $this->handler = new PNGHandler();
        }
 
+       /**
+        * @covers PNGHandler::getMetadata
+        */
        public function testInvalidFile() {
                $res = $this->handler->getMetadata( null, $this->filePath . '/README' );
                $this->assertEquals( PNGHandler::BROKEN_FILE, $res );
@@ -27,6 +39,7 @@ class PNGHandlerTest extends MediaWikiTestCase {
         * @param $filename String basename of the file to check
         * @param $expected boolean Expected result.
         * @dataProvider provideIsAnimated
+        * @covers PNGHandler::isAnimatedImage
         */
        public function testIsAnimanted( $filename, $expected ) {
                $file = $this->dataFile( $filename, 'image/png' );
@@ -45,6 +58,7 @@ class PNGHandlerTest extends MediaWikiTestCase {
         * @param $filename String
         * @param $expected Integer Total image area
         * @dataProvider provideGetImageArea
+        * @covers PNGHandler::getImageArea
         */
        public function testGetImageArea( $filename, $expected ) {
                $file = $this->dataFile( $filename, 'image/png' );
@@ -65,6 +79,7 @@ class PNGHandlerTest extends MediaWikiTestCase {
         * @param $metadata String Serialized metadata
         * @param $expected Integer One of the class constants of PNGHandler
         * @dataProvider provideIsMetadataValid
+        * @covers PNGHandler::isMetadataValid
         */
        public function testIsMetadataValid( $metadata, $expected ) {
                $actual = $this->handler->isMetadataValid( null, $metadata );
@@ -85,6 +100,7 @@ class PNGHandlerTest extends MediaWikiTestCase {
         * @param $filename String
         * @param $expected String Serialized array
         * @dataProvider provideGetMetadata
+        * @covers PNGHandler::getMetadata
         */
        public function testGetMetadata( $filename, $expected ) {
                $file = $this->dataFile( $filename, 'image/png' );
index 3bf9c59..257009b 100644 (file)
@@ -1,5 +1,8 @@
 <?php
 
+/**
+ * @todo covers tags
+ */
 class SVGMetadataExtractorTest extends MediaWikiTestCase {
 
        protected function setUp() {
@@ -10,14 +13,14 @@ class SVGMetadataExtractorTest extends MediaWikiTestCase {
        /**
         * @dataProvider provideSvgFiles
         */
-       function testGetMetadata( $infile, $expected ) {
+       public function testGetMetadata( $infile, $expected ) {
                $this->assertMetadata( $infile, $expected );
        }
 
        /**
         * @dataProvider provideSvgFilesWithXMLMetadata
         */
-       function testGetXMLMetadata( $infile, $expected ) {
+       public function testGetXMLMetadata( $infile, $expected ) {
                $r = new XMLReader();
                if ( !method_exists( $r, 'readInnerXML' ) ) {
                        $this->markTestSkipped( 'XMLReader::readInnerXML() does not exist (libxml >2.6.20 needed).' );
index 1ec34d5..8d74b98 100644 (file)
@@ -1,6 +1,11 @@
 <?php
 class TiffTest extends MediaWikiTestCase {
 
+       /** @var TiffHandler */
+       protected $handler;
+       /** @var string */
+       protected $filePath;
+
        protected function setUp() {
                parent::setUp();
                if ( !extension_loaded( 'exif' ) ) {
@@ -13,11 +18,17 @@ class TiffTest extends MediaWikiTestCase {
                $this->handler = new TiffHandler;
        }
 
+       /**
+        * @covers TiffHandler::getMetadata
+        */
        public function testInvalidFile() {
                $res = $this->handler->getMetadata( null, $this->filePath . 'README' );
                $this->assertEquals( ExifBitmapHandler::BROKEN_FILE, $res );
        }
 
+       /**
+        * @covers TiffHandler::getMetadata
+        */
        public function testTiffMetadataExtraction() {
                $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;}';
index aa0cdd2..d12e9b0 100644 (file)
@@ -1,4 +1,8 @@
 <?php
+
+/**
+ * @todo covers tags
+ */
 class XMPTest extends MediaWikiTestCase {
 
        protected function setUp() {
@@ -15,6 +19,7 @@ class XMPTest extends MediaWikiTestCase {
         * @param $expected Array expected result of parsing the xmp.
         * @param $info String Short sentence on what's being tested.
         *
+        * @throws Exception
         * @dataProvider provideXMPParse
         */
        public function testXMPParse( $xmp, $expected, $info ) {
@@ -75,7 +80,7 @@ class XMPTest extends MediaWikiTestCase {
         * @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() {
+       public function testExtendedXMP() {
                $xmpPath = __DIR__ . '/../../data/xmp/';
                $standardXMP = file_get_contents( $xmpPath . 'xmpExt.xmp' );
                $extendedXMP = file_get_contents( $xmpPath . 'xmpExt2.xmp' );
@@ -105,7 +110,7 @@ class XMPTest extends MediaWikiTestCase {
         * This test has an extended XMP block with a wrong guid (md5sum)
         * and thus should only return the StandardXMP, not the ExtendedXMP.
         */
-       function testExtendedXMPWithWrongGUID() {
+       public function testExtendedXMPWithWrongGUID() {
                $xmpPath = __DIR__ . '/../../data/xmp/';
                $standardXMP = file_get_contents( $xmpPath . 'xmpExt.xmp' );
                $extendedXMP = file_get_contents( $xmpPath . 'xmpExt2.xmp' );
@@ -134,7 +139,7 @@ class XMPTest extends MediaWikiTestCase {
         * Have a high offset to simulate a missing packet,
         * which should cause it to ignore the ExtendedXMP packet.
         */
-       function testExtendedXMPMissingPacket() {
+       public function testExtendedXMPMissingPacket() {
                $xmpPath = __DIR__ . '/../../data/xmp/';
                $standardXMP = file_get_contents( $xmpPath . 'xmpExt.xmp' );
                $extendedXMP = file_get_contents( $xmpPath . 'xmpExt2.xmp' );
index 257c40a..96bf5e4 100644 (file)
@@ -3,8 +3,9 @@ class XMPValidateTest extends MediaWikiTestCase {
 
        /**
         * @dataProvider provideDates
+        * @covers XMPValidate::validateDate
         */
-       function testValidateDate( $value, $expected ) {
+       public function testValidateDate( $value, $expected ) {
                // The method should modify $value.
                XMPValidate::validateDate( array(), $value, true );
                $this->assertEquals( $expected, $value );