MediaWiki
REL1_24
|
00001 <?php 00002 00006 class XCFHandlerTest extends MediaWikiMediaTestCase { 00007 00009 protected $handler; 00010 00011 protected function setUp() { 00012 parent::setUp(); 00013 $this->handler = new XCFHandler(); 00014 } 00015 00016 00024 public function testGetImageSize( $filename, $expectedWidth, $expectedHeight ) { 00025 $file = $this->dataFile( $filename, 'image/x-xcf' ); 00026 $actual = $this->handler->getImageSize( $file, $file->getLocalRefPath() ); 00027 $this->assertEquals( $expectedWidth, $actual[0] ); 00028 $this->assertEquals( $expectedHeight, $actual[1] ); 00029 } 00030 00031 public static function provideGetImageSize() { 00032 return array( 00033 array( '80x60-2layers.xcf', 80, 60 ), 00034 array( '80x60-RGB.xcf', 80, 60 ), 00035 array( '80x60-Greyscale.xcf', 80, 60 ), 00036 ); 00037 } 00038 00045 public function testIsMetadataValid( $metadata, $expected ) { 00046 $actual = $this->handler->isMetadataValid( null, $metadata ); 00047 $this->assertEquals( $expected, $actual ); 00048 } 00049 00050 public static function provideIsMetadataValid() { 00051 return array( 00052 array( '', XCFHandler::METADATA_BAD ), 00053 array( serialize( array( 'error' => true ) ), XCFHandler::METADATA_GOOD ), 00054 array( false, XCFHandler::METADATA_BAD ), 00055 array( serialize( array( 'colorType' => 'greyscale-alpha' ) ), XCFHandler::METADATA_GOOD ), 00056 ); 00057 } 00058 00065 public function testGetMetadata( $filename, $expected ) { 00066 $file = $this->dataFile( $filename, 'image/png' ); 00067 $actual = $this->handler->getMetadata( $file, "$this->filePath/$filename" ); 00068 $this->assertEquals( $expected, $actual ); 00069 } 00070 00071 public static function provideGetMetadata() { 00072 return array( 00073 array( '80x60-2layers.xcf', 'a:1:{s:9:"colorType";s:16:"truecolour-alpha";}' ), 00074 array( '80x60-RGB.xcf', 'a:1:{s:9:"colorType";s:16:"truecolour-alpha";}' ), 00075 array( '80x60-Greyscale.xcf', 'a:1:{s:9:"colorType";s:15:"greyscale-alpha";}' ), 00076 ); 00077 } 00078 }