Debian Codegraph @

tests/phpunit/includes/media/TiffTest.php

raw symbols SCIP
1 <?php
2
3 use MediaWiki\MainConfigNames;
4
5 /**
6 * @group Media
7 * @requires extension exif
8 */
9 class TiffTest extends MediaWikiIntegrationTestCase {
10 private const FILE_PATH = __DIR__ . '/../../data/media/';
11
12 /** @var TiffHandler */
13 protected $handler;
14
15 protected function setUp(): void {
16 parent::setUp();
17
18 $this->overrideConfigValue( MainConfigNames::ShowEXIF, true );
19
20 $this->handler = new TiffHandler;
21 }
22
23 /**
24 * @covers \TiffHandler::getSizeAndMetadata
25 */
26 public function testInvalidFile() {
27 $res = $this->handler->getSizeAndMetadata( null, self::FILE_PATH . 'README' );
28 $this->assertEquals( [ 'metadata' => [ '_error' => ExifBitmapHandler::BROKEN_FILE ] ], $res );
29 }
30
31 /**
32 * @covers \TiffHandler::getSizeAndMetadata
33 */
34 public function testTiffMetadataExtraction() {
35 $res = $this->handler->getSizeAndMetadata( null, self::FILE_PATH . 'test.tiff' );
36
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,
47 ],
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,
61 ]
62 ];
63
64 // Re-unserialize in case there are subtle differences between how versions
65 // of php serialize stuff.
66 $this->assertEquals( $expected, $res );
67 }
68 }