2 class XCFHandlerTest
extends MediaWikiMediaTestCase
{
7 protected function setUp() {
9 $this->handler
= new XCFHandler();
14 * @param string $filename
15 * @param int $expectedWidth width
16 * @param int $expectedHeigh height
17 * @dataProvider provideGetImageSize
18 * @covers XCFHandler::getImageSize
20 public function testGetImageSize( $filename, $expectedWidth, $expectedHeight ) {
21 $file = $this->dataFile( $filename, 'image/x-xcf' );
22 $actual = $this->handler
->getImageSize( $file, $file->getLocalRefPath() );
23 $this->assertEquals( $expectedWidth, $actual[0] );
24 $this->assertEquals( $expectedHeight, $actual[1] );
27 public static function provideGetImageSize() {
29 array( '80x60-2layers.xcf', 80, 60 ),
30 array( '80x60-RGB.xcf', 80, 60 ),
31 array( '80x60-Greyscale.xcf', 80, 60 ),
36 * @param string $metadata Serialized metadata
37 * @param int $expected One of the class constants of XCFHandler
38 * @dataProvider provideIsMetadataValid
39 * @covers XCFHandler::isMetadataValid
41 public function testIsMetadataValid( $metadata, $expected ) {
42 $actual = $this->handler
->isMetadataValid( null, $metadata );
43 $this->assertEquals( $expected, $actual );
46 public static function provideIsMetadataValid() {
48 array( '', XCFHandler
::METADATA_BAD
),
49 array( serialize( array( 'error' => true ) ), XCFHandler
::METADATA_GOOD
),
50 array( false, XCFHandler
::METADATA_BAD
),
51 array( serialize( array( 'colorType' => 'greyscale-alpha' ) ), XCFHandler
::METADATA_GOOD
),
56 * @param string $filename
57 * @param string $expected Serialized array
58 * @dataProvider provideGetMetadata
59 * @covers XCFHandler::getMetadata
61 public function testGetMetadata( $filename, $expected ) {
62 $file = $this->dataFile( $filename, 'image/png' );
63 $actual = $this->handler
->getMetadata( $file, "$this->filePath/$filename" );
64 $this->assertEquals( $expected, $actual );
67 public static function provideGetMetadata() {
69 array( '80x60-2layers.xcf', 'a:1:{s:9:"colorType";s:16:"truecolour-alpha";}' ),
70 array( '80x60-RGB.xcf', 'a:1:{s:9:"colorType";s:16:"truecolour-alpha";}' ),
71 array( '80x60-Greyscale.xcf', 'a:1:{s:9:"colorType";s:15:"greyscale-alpha";}' ),