Merge "AutoLoader: Use require_once rather than require"
[mediawiki.git] / tests / phpunit / includes / media / TiffTest.php
blob9eebc0418736d1c136446e5080d139f7ed62c844
1 <?php
3 use MediaWiki\MainConfigNames;
5 /**
6 * @group Media
7 * @requires extension exif
8 */
9 class TiffTest extends MediaWikiIntegrationTestCase {
10 private const FILE_PATH = __DIR__ . '/../../data/media/';
12 /** @var TiffHandler */
13 protected $handler;
15 protected function setUp(): void {
16 parent::setUp();
18 $this->overrideConfigValue( MainConfigNames::ShowEXIF, true );
20 $this->handler = new TiffHandler;
23 /**
24 * @covers \TiffHandler::getSizeAndMetadata
26 public function testInvalidFile() {
27 $res = $this->handler->getSizeAndMetadata( null, self::FILE_PATH . 'README' );
28 $this->assertEquals( [ 'metadata' => [ '_error' => ExifBitmapHandler::BROKEN_FILE ] ], $res );
31 /**
32 * @covers \TiffHandler::getSizeAndMetadata
34 public function testTiffMetadataExtraction() {
35 $res = $this->handler->getSizeAndMetadata( null, self::FILE_PATH . 'test.tiff' );
37 $expected = [
38 'width' => 20,
39 'height' => 20,
40 'metadata' => [
41 'ImageWidth' => 20,
42 'ImageLength' => 20,
43 'BitsPerSample' => [
44 0 => 8,
45 1 => 8,
46 2 => 8,
48 'Compression' => 5,
49 'PhotometricInterpretation' => 2,
50 'ImageDescription' => 'Created with GIMP',
51 'StripOffsets' => 8,
52 'Orientation' => 1,
53 'SamplesPerPixel' => 3,
54 'RowsPerStrip' => 64,
55 'StripByteCounts' => 238,
56 'XResolution' => '1207959552/16777216',
57 'YResolution' => '1207959552/16777216',
58 'PlanarConfiguration' => 1,
59 'ResolutionUnit' => 2,
60 'MEDIAWIKI_EXIF_VERSION' => 2,
64 // Re-unserialize in case there are subtle differences between how versions
65 // of php serialize stuff.
66 $this->assertEquals( $expected, $res );