X-Git-Url: http://git.heureux-cyclage.org/?a=blobdiff_plain;f=tests%2Fphpunit%2Fincludes%2Fmedia%2FBitmapMetadataHandlerTest.php;h=b221b8325bb66706c56215dcaa3d015370909c97;hb=fba656f9861bab41f0d94735bbc5cde672575fd8;hp=88f87ef9e3723b256460e76b0b8991fd691f8c84;hpb=1a9b7b2238c4da398a06ac89fbe2cd418be42e6e;p=lhc%2Fweb%2Fwiklou.git diff --git a/tests/phpunit/includes/media/BitmapMetadataHandlerTest.php b/tests/phpunit/includes/media/BitmapMetadataHandlerTest.php index 88f87ef9e3..b221b8325b 100644 --- a/tests/phpunit/includes/media/BitmapMetadataHandlerTest.php +++ b/tests/phpunit/includes/media/BitmapMetadataHandlerTest.php @@ -1,7 +1,11 @@ setMwGlobals( 'wgShowEXIF', false ); + $this->filePath = __DIR__ . '/../../data/media/'; } @@ -14,14 +18,15 @@ class BitmapMetadataHandlerTest extends MediaWikiTestCase { * translation (to en) where XMP should win. */ public function testMultilingualCascade() { + global $wgShowEXIF; + if ( !wfDl( 'exif' ) ) { $this->markTestSkipped( "This test needs the exif extension." ); } if ( !wfDl( 'xml' ) ) { $this->markTestSkipped( "This test needs the xml extension." ); } - global $wgShowEXIF; - $oldExif = $wgShowEXIF; + $wgShowEXIF = true; $meta = BitmapMetadataHandler::Jpeg( $this->filePath . @@ -29,16 +34,14 @@ class BitmapMetadataHandlerTest extends MediaWikiTestCase { $expected = array( 'x-default' => 'right(iptc)', - 'en' => 'right translation', - '_type' => 'lang' + 'en' => 'right translation', + '_type' => 'lang' ); - + $this->assertArrayHasKey( 'ImageDescription', $meta, 'Did not extract any ImageDescription info?!' ); $this->assertEquals( $expected, $meta['ImageDescription'] ); - - $wgShowEXIF = $oldExif; } /** @@ -73,6 +76,7 @@ class BitmapMetadataHandlerTest extends MediaWikiTestCase { $this->assertEquals( '2020:07:14 01:36:05', $meta['DateTimeDigitized'] ); $this->assertEquals( '1997:03:02 00:01:02', $meta['DateTimeOriginal'] ); } + /** * File has an invalid time (+ one valid but really weird time) * that shouldn't be included @@ -118,25 +122,27 @@ class BitmapMetadataHandlerTest extends MediaWikiTestCase { } $handler = new BitmapMetadataHandler(); $result = $handler->png( $this->filePath . 'xmp.png' ); - $expected = array ( + $expected = array( 'frameCount' => 0, 'loopCount' => 1, 'duration' => 0, 'bitDepth' => 1, 'colorType' => 'index-coloured', - 'metadata' => array ( + 'metadata' => array( 'SerialNumber' => '123456789', '_MW_PNG_VERSION' => 1, ), ); - $this->assertEquals( $expected, $result ); + $this->assertEquals( $expected, $result ); } + public function testPNGNative() { $handler = new BitmapMetadataHandler(); $result = $handler->png( $this->filePath . 'Png-native-test.png' ); $expected = 'http://example.com/url'; - $this->assertEquals( $expected, $result['metadata']['Identifier']['x-default'] ); + $this->assertEquals( $expected, $result['metadata']['Identifier']['x-default'] ); } + public function testTiffByteOrder() { $handler = new BitmapMetadataHandler(); $res = $handler->getTiffByteOrder( $this->filePath . 'test.tiff' );