6 class XCFHandlerTest
extends MediaWikiMediaTestCase
{
11 protected function setUp() {
13 $this->handler
= new XCFHandler();
17 * @param string $filename
18 * @param int $expectedWidth Width
19 * @param int $expectedHeight Height
20 * @dataProvider provideGetImageSize
21 * @covers XCFHandler::getImageSize
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] );
30 public static function provideGetImageSize() {
32 [ '80x60-2layers.xcf', 80, 60 ],
33 [ '80x60-RGB.xcf', 80, 60 ],
34 [ '80x60-Greyscale.xcf', 80, 60 ],
39 * @param string $metadata Serialized metadata
40 * @param int $expected One of the class constants of XCFHandler
41 * @dataProvider provideIsMetadataValid
42 * @covers XCFHandler::isMetadataValid
44 public function testIsMetadataValid( $metadata, $expected ) {
45 $actual = $this->handler
->isMetadataValid( null, $metadata );
46 $this->assertEquals( $expected, $actual );
49 public static function provideIsMetadataValid() {
51 [ '', XCFHandler
::METADATA_BAD
],
52 [ serialize( [ 'error' => true ] ), XCFHandler
::METADATA_GOOD
],
53 [ false, XCFHandler
::METADATA_BAD
],
54 [ serialize( [ 'colorType' => 'greyscale-alpha' ] ), XCFHandler
::METADATA_GOOD
],
59 * @param string $filename
60 * @param string $expected Serialized array
61 * @dataProvider provideGetMetadata
62 * @covers XCFHandler::getMetadata
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 );
70 public static function provideGetMetadata() {
72 [ '80x60-2layers.xcf', 'a:1:{s:9:"colorType";s:16:"truecolour-alpha";}' ],
73 [ '80x60-RGB.xcf', 'a:1:{s:9:"colorType";s:16:"truecolour-alpha";}' ],
74 [ '80x60-Greyscale.xcf', 'a:1:{s:9:"colorType";s:15:"greyscale-alpha";}' ],