3 class ExifBitmapTest
extends MediaWikiTestCase
{
5 public function setUp() {
7 $this->showExif
= $wgShowEXIF;
11 public function tearDown() {
13 $wgShowEXIF = $this->showExif
;
16 public function testIsOldBroken() {
17 if ( !wfDl( 'exif' ) ) {
18 $this->markTestIncomplete( "This test needs the exif extension." );
20 $handler = new ExifBitmapHandler
;
21 $res = $handler->isMetadataValid( null, ExifBitmapHandler
::OLD_BROKEN_FILE
);
22 $this->assertEquals( ExifBitmapHandler
::METADATA_COMPATIBLE
, $res );
24 public function testIsBrokenFile() {
25 if ( !wfDl( 'exif' ) ) {
26 $this->markTestIncomplete( "This test needs the exif extension." );
28 $handler = new ExifBitmapHandler
;
29 $res = $handler->isMetadataValid( null, ExifBitmapHandler
::BROKEN_FILE
);
30 $this->assertEquals( ExifBitmapHandler
::METADATA_GOOD
, $res );
32 public function testIsInvalid() {
33 if ( !wfDl( 'exif' ) ) {
34 $this->markTestIncomplete( "This test needs the exif extension." );
36 $handler = new ExifBitmapHandler
;
37 $res = $handler->isMetadataValid( null, 'Something Invalid Here.' );
38 $this->assertEquals( ExifBitmapHandler
::METADATA_BAD
, $res );
40 public function testGoodMetadata() {
41 if ( !wfDl( 'exif' ) ) {
42 $this->markTestIncomplete( "This test needs the exif extension." );
44 $handler = new ExifBitmapHandler
;
45 $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;}';
46 $res = $handler->isMetadataValid( null, $meta );
47 $this->assertEquals( ExifBitmapHandler
::METADATA_GOOD
, $res );
49 public function testIsOldGood() {
50 if ( !wfDl( 'exif' ) ) {
51 $this->markTestIncomplete( "This test needs the exif extension." );
53 $handler = new ExifBitmapHandler
;
54 $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;}';
55 $res = $handler->isMetadataValid( null, $meta );
56 $this->assertEquals( ExifBitmapHandler
::METADATA_COMPATIBLE
, $res );
58 // Handle metadata from paged tiff handler (gotten via instant commons)
60 public function testPagedTiffHandledGracefully() {
61 if ( !wfDl( 'exif' ) ) {
62 $this->markTestIncomplete( "This test needs the exif extension." );
64 $handler = new ExifBitmapHandler
;
65 $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";}';
66 $res = $handler->isMetadataValid( null, $meta );
67 $this->assertEquals( ExifBitmapHandler
::METADATA_BAD
, $res );