MediaWiki  REL1_19
PNGMetadataExtractorTest.php
Go to the documentation of this file.
00001 <?php
00002 class PNGMetadataExtractorTest extends MediaWikiTestCase {
00003 
00004         function setUp() {
00005                 $this->filePath = dirname( __FILE__ ) . '/../../data/media/';   
00006         }
00010         function testPngNativetZtxt() {
00011                 $meta = PNGMetadataExtractor::getMetadata( $this->filePath .
00012                         'Png-native-test.png' );
00013                 $expected = "foo bar baz foo foo foo foof foo foo foo foo";
00014                 $this->assertArrayHasKey( 'text', $meta );
00015                 $meta = $meta['text'];
00016                 $this->assertArrayHasKey( 'Make', $meta );
00017                 $this->assertArrayHasKey( 'x-default', $meta['Make'] );
00018 
00019                 $this->assertEquals( $expected, $meta['Make']['x-default'] );
00020         }
00021 
00025         function testPngNativeText() {
00026                 $meta = PNGMetadataExtractor::getMetadata( $this->filePath .
00027                         'Png-native-test.png' );
00028                 $expected = "Some long image desc";
00029                 $this->assertArrayHasKey( 'text', $meta );
00030                 $meta = $meta['text'];
00031                 $this->assertArrayHasKey( 'ImageDescription', $meta );
00032                 $this->assertArrayHasKey( 'x-default', $meta['ImageDescription'] );
00033                 $this->assertArrayHasKey( '_type', $meta['ImageDescription'] );
00034 
00035                 $this->assertEquals( $expected, $meta['ImageDescription']['x-default'] );
00036         }
00037 
00042         function testPngNativeTextNonAscii() {
00043                 $meta = PNGMetadataExtractor::getMetadata( $this->filePath .
00044                         'Png-native-test.png' );
00045 
00046                 // Note the Copyright symbol here is a utf-8 one
00047                 // (aka \xC2\xA9) where in the file its iso-8859-1
00048                 // encoded as just \xA9.
00049                 $expected = "© 2010 Bawolff";
00050 
00051 
00052                 $this->assertArrayHasKey( 'text', $meta );
00053                 $meta = $meta['text'];
00054                 $this->assertArrayHasKey( 'Copyright', $meta );
00055                 $this->assertArrayHasKey( 'x-default', $meta['Copyright'] );
00056 
00057                 $this->assertEquals( $expected, $meta['Copyright']['x-default'] );
00058         }
00059 
00078 
00091