3c6c46a930b3ec4cca655f33b8f80aeb72d4c2e0
3 class ExifBitmapTest
extends MediaWikiTestCase
{
5 public function testIsOldBroken() {
6 if ( wfDl( 'exif' ) ) {
7 $this->markTestIncomplete( "This test needs the exif extension." );
9 $handler = new ExifBitmapHandler
;
10 $res = $handler->isMetadataValid( null, ExifBitmapHandler
::OLD_BROKEN_FILE
);
11 $this->assertEquals( ExifBitmapHandler
::METADATA_COMPATIBLE
, $res );
13 public function testIsBrokenFile() {
14 if ( !wfDl( 'exif' ) ) {
15 $this->markTestIncomplete( "This test needs the exif extension." );
17 $handler = new ExifBitmapHandler
;
18 $res = $handler->isMetadataValid( null, ExifBitmapHandler
::BROKEN_FILE
);
19 $this->assertEquals( ExifBitmapHandler
::METADATA_GOOD
, $res );
21 public function testIsInvalid() {
22 if ( !wfDl( 'exif' ) ) {
23 $this->markTestIncomplete( "This test needs the exif extension." );
25 $handler = new ExifBitmapHandler
;
26 $res = $handler->isMetadataValid( null, 'Something Invalid Here.' );
27 $this->assertEquals( ExifBitmapHandler
::METADATA_BAD
, $res );
29 public function testGoodMetadata() {
30 if ( !wfDl( 'exif' ) ) {
31 $this->markTestIncomplete( "This test needs the exif extension." );
33 $handler = new ExifBitmapHandler
;
34 $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;}';
35 $res = $handler->isMetadataValid( null, $meta );
36 $this->assertEquals( ExifBitmapHandler
::METADATA_GOOD
, $res );
38 public function testIsOldGood() {
39 if ( !wfDl( 'exif' ) ) {
40 $this->markTestIncomplete( "This test needs the exif extension." );
42 $handler = new ExifBitmapHandler
;
43 $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;}';
44 $res = $handler->isMetadataValid( null, $meta );
45 $this->assertEquals( ExifBitmapHandler
::METADATA_COMPATIBLE
, $res );
47 // Handle metadata from paged tiff handler (gotten via instant commons)
49 public function testPagedTiffHandledGracefully() {
50 if ( !wfDl( 'exif' ) ) {
51 $this->markTestIncomplete( "This test needs the exif extension." );
53 $handler = new ExifBitmapHandler
;
54 $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";}';
55 $res = $handler->isMetadataValid( null, $meta );
56 $this->assertEquals( ExifBitmapHandler
::METADATA_BAD
, $res );