MediaWiki  1.30.0
TiffTest.php
Go to the documentation of this file.
1 <?php
2 
6 class TiffTest extends MediaWikiTestCase {
7 
9  protected $handler;
11  protected $filePath;
12 
13  protected function setUp() {
14  parent::setUp();
15  $this->checkPHPExtension( 'exif' );
16 
17  $this->setMwGlobals( 'wgShowEXIF', true );
18 
19  $this->filePath = __DIR__ . '/../../data/media/';
20  $this->handler = new TiffHandler;
21  }
22 
26  public function testInvalidFile() {
27  $res = $this->handler->getMetadata( null, $this->filePath . 'README' );
28  $this->assertEquals( ExifBitmapHandler::BROKEN_FILE, $res );
29  }
30 
34  public function testTiffMetadataExtraction() {
35  $res = $this->handler->getMetadata( null, $this->filePath . 'test.tiff' );
36 
37  // @codingStandardsIgnoreStart Ignore Generic.Files.LineLength.TooLong
38  $expected = '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;}';
39  // @codingStandardsIgnoreEnd
40 
41  // Re-unserialize in case there are subtle differences between how versions
42  // of php serialize stuff.
43  $this->assertEquals( unserialize( $expected ), unserialize( $res ) );
44  }
45 }
unserialize
unserialize( $serialized)
Definition: ApiMessage.php:185
$res
$res
Definition: database.txt:21
TiffTest
Media.
Definition: TiffTest.php:6
TiffTest\$filePath
string $filePath
Definition: TiffTest.php:11
php
injection txt This is an overview of how MediaWiki makes use of dependency injection The design described here grew from the discussion of RFC T384 The term dependency this means that anything an object needs to operate should be injected from the the object itself should only know narrow no concrete implementation of the logic it relies on The requirement to inject everything typically results in an architecture that based on two main types of and essentially stateless service objects that use other service objects to operate on the value objects As of the beginning MediaWiki is only starting to use the DI approach Much of the code still relies on global state or direct resulting in a highly cyclical dependency which acts as the top level factory for services in MediaWiki which can be used to gain access to default instances of various services MediaWikiServices however also allows new services to be defined and default services to be redefined Services are defined or redefined by providing a callback the instantiator that will return a new instance of the service When it will create an instance of MediaWikiServices and populate it with the services defined in the files listed by thereby bootstrapping the DI framework Per $wgServiceWiringFiles lists includes ServiceWiring php
Definition: injection.txt:35
TiffTest\testInvalidFile
testInvalidFile()
TiffHandler::getMetadata.
Definition: TiffTest.php:26
handler
this hook is for auditing only or null if authentication failed before getting that far or null if we can t even determine that probably a stub it is not rendered in wiki pages or galleries in category pages allow injecting custom HTML after the section Any uses of the hook need to handle escaping see BaseTemplate::getToolbox and BaseTemplate::makeListItem for details on the format of individual items inside of this array or by returning and letting standard HTTP rendering take place modifiable or by returning false and taking over the output modifiable modifiable after all normalizations have been except for the $wgMaxImageArea check set to true or false to override the $wgMaxImageArea check result gives extension the possibility to transform it themselves set to a MediaTransformOutput the error message to be returned in an array you should do so by altering $wgNamespaceProtection and $wgNamespaceContentModels outside the handler
Definition: hooks.txt:781
TiffHandler
Handler for Tiff images.
Definition: Tiff.php:29
MediaWikiTestCase\setMwGlobals
setMwGlobals( $pairs, $value=null)
Sets a global, maintaining a stashed version of the previous global to be restored in tearDown.
Definition: MediaWikiTestCase.php:672
MediaWikiTestCase
Definition: MediaWikiTestCase.php:15
TiffTest\setUp
setUp()
Definition: TiffTest.php:13
TiffTest\$handler
TiffHandler $handler
Definition: TiffTest.php:9
MediaWikiTestCase\checkPHPExtension
checkPHPExtension( $extName)
Check if $extName is a loaded PHP extension, will skip the test whenever it is not loaded.
Definition: MediaWikiTestCase.php:1770
ExifBitmapHandler\BROKEN_FILE
const BROKEN_FILE
Definition: ExifBitmap.php:31
TiffTest\testTiffMetadataExtraction
testTiffMetadataExtraction()
TiffHandler::getMetadata.
Definition: TiffTest.php:34