2 class JpegMetadataExtractorTest
extends MediaWikiTestCase
{
4 public function setUp() {
5 $this->filePath
= dirname( __FILE__
) . '/../../data/media/';
8 public function testUtf8Comment() {
9 $res = JpegMetadataExtractor
::segmentSplitter( $this->filePath
. 'jpeg-comment-utf.jpg' );
10 $this->assertEquals( array( 'UTF-8 JPEG Comment — ¼' ), $res['COM'] );
12 /** The file is iso-8859-1, but it should get auto converted */
13 public function testIso88591Comment() {
14 $res = JpegMetadataExtractor
::segmentSplitter( $this->filePath
. 'jpeg-comment-iso8859-1.jpg' );
15 $this->assertEquals( array( 'ISO-8859-1 JPEG Comment - ¼' ), $res['COM'] );
17 /** Comment values that are non-textual (random binary junk) should not be shown.
18 * The example test file has a comment with a 0x5 byte in it which is a control character
19 * and considered binary junk for our purposes.
21 public function testBinaryCommentStripped() {
22 $res = JpegMetadataExtractor
::segmentSplitter( $this->filePath
. 'jpeg-comment-binary.jpg' );
23 $this->assertEmpty( $res['COM'] );
25 /* Very rarely a file can have multiple comments.
26 * Order of comments is based on order inside the file.
28 public function testMultipleComment() {
29 $res = JpegMetadataExtractor
::segmentSplitter( $this->filePath
. 'jpeg-comment-multiple.jpg' );
30 $this->assertEquals( array( 'foo', 'bar' ), $res['COM'] );