# 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",
* 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' ) ) {
*
* There's more extensive tests of comment extraction in
* JpegMetadataExtractorTests.php
+ * @covers BitmapMetadataHandler::Jpeg
*/
public function testJpegComment() {
$meta = BitmapMetadataHandler::Jpeg( $this->filePath .
/**
* 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 .
$this->assertEquals( 'Created with GIMP', $meta['JPEGFileComment'][0] );
}
+ /**
+ * @covers BitmapMetadataHandler::Jpeg
+ */
public function testIPTCDates() {
$meta = BitmapMetadataHandler::Jpeg( $this->filePath .
'iptc-timetest.jpg' );
/**
* 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 .
* 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();
$this->assertEquals( $expected, $actual );
}
+ /**
+ * @covers BitmapMetadataHandler::png
+ */
public function testPNGXMP() {
if ( !extension_loaded( 'xml' ) ) {
$this->markTestSkipped( "This test needs the xml extension." );
$this->assertEquals( $expected, $result );
}
+ /**
+ * @covers BitmapMetadataHandler::png
+ */
public function testPNGNative() {
$handler = new BitmapMetadataHandler();
$result = $handler->png( $this->filePath . 'Png-native-test.png' );
$this->assertEquals( $expected, $result['metadata']['Identifier']['x-default'] );
}
+ /**
+ * @covers BitmapMetadataHandler::getTiffByteOrder
+ */
public function testTiffByteOrder() {
$handler = new BitmapMetadataHandler();
$res = $handler->getTiffByteOrder( $this->filePath . 'test.tiff' );
/**
* @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 );
);
}
- 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.
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;
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 '';
- }
-}
class ExifBitmapTest extends MediaWikiTestCase {
+ /**
+ * @var ExifBitmapHandler
+ */
+ protected $handler;
+
protected function setUp() {
parent::setUp();
if ( !extension_loaded( 'exif' ) ) {
}
+ /**
+ * @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
$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' ),
$this->assertEquals( $expected, $res );
}
- function testConvertMetadataSoftware() {
+ /**
+ * @covers ExifBitmapHandler::convertMetadataVersion
+ */
+ public function testConvertMetadataSoftware() {
$metadata = array(
'Software' => array( array( 'GIMP', '1.1' ) ),
'MEDIAWIKI_EXIF_VERSION' => 2,
$this->assertEquals( $expected, $res );
}
- function testConvertMetadataSoftwareNormal() {
+ /**
+ * @covers ExifBitmapHandler::convertMetadataVersion
+ */
+ public function testConvertMetadataSoftwareNormal() {
$metadata = array(
'Software' => array( "GIMP 1.2", "vim" ),
'MEDIAWIKI_EXIF_VERSION' => 2,
* Tests related to auto rotation.
*
* @group medium
+ *
+ * @todo covers tags
*/
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." );
}
*
* @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." );
}
* 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 );
*
* @dataProvider provideFilesNoAutoRotate
*/
- function testRotationRenderingNoAutoRotate( $name, $type, $info, $thumbs ) {
+ public function testRotationRenderingNoAutoRotate( $name, $type, $info, $thumbs ) {
$this->setMwGlobals( 'wgEnableAutoRotation', false );
foreach ( $thumbs as $size => $out ) {
/**
* @dataProvider provideBitmapExtractPreRotationDimensions
*/
- function testBitmapExtractPreRotationDimensions( $rotation, $expected ) {
+ public function testBitmapExtractPreRotationDimensions( $rotation, $expected ) {
$result = $this->handler->extractPreRotationDimensions( array(
'physicalWidth' => self::TEST_WIDTH,
'physicalHeight' => self::TEST_HEIGHT,
<?php
class ExifTest extends MediaWikiTestCase {
+ /** @var string */
+ protected $mediaPath;
+
protected function setUp() {
parent::setUp();
if ( !extension_loaded( 'exif' ) ) {
--- /dev/null
+<?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
<?php
+
+/**
+ * @todo covers tags
+ */
class FormatMetadataTest extends MediaWikiTestCase {
+ /** @var FSFileBackend */
+ protected $backend;
+ /** @var FSRepo */
+ protected $repo;
+
protected function setUp() {
parent::setUp();
* @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 );
<?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();
$this->handler = new GIFHandler();
}
+ /**
+ * @covers GIFHandler::getMetadata
+ */
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 provideIsAnimated
+ * @covers GIFHandler::isAnimatedImage
*/
public function testIsAnimanted( $filename, $expected ) {
$file = $this->dataFile( $filename, 'image/gif' );
* @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' );
* @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 );
* @param $filename String
* @param $expected String Serialized array
* @dataProvider provideGetMetadata
+ * @covers GIFHandler::getMetadata
*/
public function testGetMetadata( $filename, $expected ) {
$file = $this->dataFile( $filename, 'image/gif' );
<?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
$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"
$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"
$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";
* 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();
* We also use this test to test padding bytes don't
* screw stuff up
*
- * @param $file filename
+ * @param string $file filename
*
* @dataProvider provideUtf8Comment
*/
<?php
+/**
+ * @todo covers tags
+ */
class JpegTest extends MediaWikiTestCase {
protected function setUp() {
<?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,
<?php
+
+/**
+ * @todo covers tags
+ */
class PNGMetadataExtractorTest extends MediaWikiTestCase {
protected function setUp() {
/**
* Tests zTXt tag (compressed textual metadata)
*/
- function testPngNativetZtxt() {
+ public function testPngNativetZtxt() {
$this->checkPHPExtension( 'zlib' );
$meta = PNGMetadataExtractor::getMetadata( $this->filePath .
/**
* 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";
* 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' );
* 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' );
/**
* Given a normal static PNG, check the animation metadata returned.
*/
- function testStaticPngAnimationMetadata() {
+ public function testStaticPngAnimationMetadata() {
$meta = PNGMetadataExtractor::getMetadata( $this->filePath .
'Png-native-test.png' );
* 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' );
$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'] );
<?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();
$this->handler = new PNGHandler();
}
+ /**
+ * @covers PNGHandler::getMetadata
+ */
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 provideIsAnimated
+ * @covers PNGHandler::isAnimatedImage
*/
public function testIsAnimanted( $filename, $expected ) {
$file = $this->dataFile( $filename, 'image/png' );
* @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' );
* @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 );
* @param $filename String
* @param $expected String Serialized array
* @dataProvider provideGetMetadata
+ * @covers PNGHandler::getMetadata
*/
public function testGetMetadata( $filename, $expected ) {
$file = $this->dataFile( $filename, 'image/png' );
<?php
+/**
+ * @todo covers tags
+ */
class SVGMetadataExtractorTest extends MediaWikiTestCase {
protected function setUp() {
/**
* @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).' );
<?php
class TiffTest extends MediaWikiTestCase {
+ /** @var TiffHandler */
+ protected $handler;
+ /** @var string */
+ protected $filePath;
+
protected function setUp() {
parent::setUp();
if ( !extension_loaded( 'exif' ) ) {
$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;}';
<?php
+
+/**
+ * @todo covers tags
+ */
class XMPTest extends MediaWikiTestCase {
protected function setUp() {
* @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 ) {
* @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' );
* 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' );
* 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' );
/**
* @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 );