MediaWiki REL1_31
XCFTest.php
Go to the documentation of this file.
1<?php
2
7
9 protected $handler;
10
11 protected function setUp() {
12 parent::setUp();
13 $this->handler = new XCFHandler();
14 }
15
23 public function testGetImageSize( $filename, $expectedWidth, $expectedHeight ) {
24 $file = $this->dataFile( $filename, 'image/x-xcf' );
25 $actual = $this->handler->getImageSize( $file, $file->getLocalRefPath() );
26 $this->assertEquals( $expectedWidth, $actual[0] );
27 $this->assertEquals( $expectedHeight, $actual[1] );
28 }
29
30 public static function provideGetImageSize() {
31 return [
32 [ '80x60-2layers.xcf', 80, 60 ],
33 [ '80x60-RGB.xcf', 80, 60 ],
34 [ '80x60-Greyscale.xcf', 80, 60 ],
35 ];
36 }
37
44 public function testIsMetadataValid( $metadata, $expected ) {
45 $actual = $this->handler->isMetadataValid( null, $metadata );
46 $this->assertEquals( $expected, $actual );
47 }
48
49 public static function provideIsMetadataValid() {
50 return [
52 [ serialize( [ 'error' => true ] ), XCFHandler::METADATA_GOOD ],
53 [ false, XCFHandler::METADATA_BAD ],
54 [ serialize( [ 'colorType' => 'greyscale-alpha' ] ), XCFHandler::METADATA_GOOD ],
55 ];
56 }
57
64 public function testGetMetadata( $filename, $expected ) {
65 $file = $this->dataFile( $filename, 'image/png' );
66 $actual = $this->handler->getMetadata( $file, "$this->filePath/$filename" );
67 $this->assertEquals( $expected, $actual );
68 }
69
70 public static function provideGetMetadata() {
71 return [
72 [ '80x60-2layers.xcf',
73 'a:1:{s:9:"colorType";s:16:"truecolour-alpha";}'
74 ],
75 [ '80x60-RGB.xcf',
76 'a:1:{s:9:"colorType";s:16:"truecolour-alpha";}'
77 ],
78 [ '80x60-Greyscale.xcf',
79 'a:1:{s:9:"colorType";s:15:"greyscale-alpha";}'
80 ],
81 ];
82 }
83}
serialize()
const METADATA_GOOD
Specificly for testing Media handlers.
dataFile( $name, $type=null)
Utility function: Get a new file object for a file on disk but not actually in db.
static provideGetMetadata()
Definition XCFTest.php:70
testGetMetadata( $filename, $expected)
Definition XCFTest.php:64
XCFHandler $handler
Definition XCFTest.php:9
static provideGetImageSize()
Definition XCFTest.php:30
testIsMetadataValid( $metadata, $expected)
Definition XCFTest.php:44
testGetImageSize( $filename, $expectedWidth, $expectedHeight)
Definition XCFTest.php:23
static provideIsMetadataValid()
Definition XCFTest.php:49
Handler for the Gimp's native file format; getimagesize() doesn't support these files.
Definition XCF.php:35
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:930