7 class JpegTest
extends MediaWikiMediaTestCase
{
9 protected function setUp() {
11 $this->checkPHPExtension( 'exif' );
13 $this->setMwGlobals( 'wgShowEXIF', true );
15 $this->handler
= new JpegHandler
;
18 public function testInvalidFile() {
19 $file = $this->dataFile( 'README', 'image/jpeg' );
20 $res = $this->handler
->getMetadata( $file, $this->filePath
. 'README' );
21 $this->assertEquals( ExifBitmapHandler
::BROKEN_FILE
, $res );
24 public function testJpegMetadataExtraction() {
25 $file = $this->dataFile( 'test.jpg', 'image/jpeg' );
26 $res = $this->handler
->getMetadata( $file, $this->filePath
. 'test.jpg' );
27 // @codingStandardsIgnoreStart Ignore Generic.Files.LineLength.TooLong
28 $expected = 'a:7:{s:16:"ImageDescription";s:9:"Test file";s:11:"XResolution";s:4:"72/1";s:11:"YResolution";s:4:"72/1";s:14:"ResolutionUnit";i:2;s:16:"YCbCrPositioning";i:1;s:15:"JPEGFileComment";a:1:{i:0;s:17:"Created with GIMP";}s:22:"MEDIAWIKI_EXIF_VERSION";i:2;}';
29 // @codingStandardsIgnoreEnd
31 // Unserialize in case serialization format ever changes.
32 $this->assertEquals( unserialize( $expected ), unserialize( $res ) );
36 * @covers JpegHandler::getCommonMetaArray
38 public function testGetIndependentMetaArray() {
39 $file = $this->dataFile( 'test.jpg', 'image/jpeg' );
40 $res = $this->handler
->getCommonMetaArray( $file );
42 'ImageDescription' => 'Test file',
43 'XResolution' => '72/1',
44 'YResolution' => '72/1',
45 'ResolutionUnit' => 2,
46 'YCbCrPositioning' => 1,
47 'JPEGFileComment' => array(
52 $this->assertEquals( $res, $expected );