From: Brian Wolff Date: Mon, 24 Oct 2011 02:47:22 +0000 (+0000) Subject: (follow-up r100575 / r99477) unit-tests for jpegMetadataExtractor dealing with paddin... X-Git-Tag: 1.31.0-rc.0~26941 X-Git-Url: http://git.cyclocoop.org/%22.%24info%5B?a=commitdiff_plain;h=19d0d43aa551b494ff4732fee50269f18791cf55;p=lhc%2Fweb%2Fwiklou.git (follow-up r100575 / r99477) unit-tests for jpegMetadataExtractor dealing with padding bytes. --- diff --git a/tests/phpunit/data/media/README b/tests/phpunit/data/media/README index 2e2c565d6b..fe3bc68299 100644 --- a/tests/phpunit/data/media/README +++ b/tests/phpunit/data/media/README @@ -25,7 +25,8 @@ test.tiff, test.jpg, jpeg-comment-multiple.jpg, jpeg-comment-utf.jpg, jpeg-comment-iso8859-1.jpg, jpeg-comment-binary.jpg, jpeg-xmp-psir.jpg, jpeg-xmp-alt.jpg, animated.gif, exif-user-comment.jpg, animated-xmp.gif, iptc-timetest-invalid.jpg, jpeg-iptc-bad-hash.jpg, iptc-timetest.jpg, -xmp.png, nonanimated.gif, exif-gps.jpg, jpeg-xmp-psir.xmp, jpeg-iptc-good-hash.jpg +xmp.png, nonanimated.gif, exif-gps.jpg, jpeg-xmp-psir.xmp, jpeg-iptc-good-hash.jpg, +jpeg-padding-even.jpg, jpeg-padding-odd.jpg Are all by Bawolff. I don't think they contain enough originality to claim copyright, but on the off chance they do, feel free to use them however you feel fit, without restriction. diff --git a/tests/phpunit/data/media/jpeg-padding-even.jpg b/tests/phpunit/data/media/jpeg-padding-even.jpg new file mode 100644 index 0000000000..c83c66bd2c Binary files /dev/null and b/tests/phpunit/data/media/jpeg-padding-even.jpg differ diff --git a/tests/phpunit/data/media/jpeg-padding-odd.jpg b/tests/phpunit/data/media/jpeg-padding-odd.jpg new file mode 100644 index 0000000000..25b9330890 Binary files /dev/null and b/tests/phpunit/data/media/jpeg-padding-odd.jpg differ diff --git a/tests/phpunit/includes/media/JpegMetadataExtractorTest.php b/tests/phpunit/includes/media/JpegMetadataExtractorTest.php index 2cfffdbf02..5bf9bfe7c7 100644 --- a/tests/phpunit/includes/media/JpegMetadataExtractorTest.php +++ b/tests/phpunit/includes/media/JpegMetadataExtractorTest.php @@ -12,10 +12,25 @@ class JpegMetadataExtractorTest extends MediaWikiTestCase { $this->filePath = dirname( __FILE__ ) . '/../../data/media/'; } - public function testUtf8Comment() { - $res = JpegMetadataExtractor::segmentSplitter( $this->filePath . 'jpeg-comment-utf.jpg' ); + /** + * We also use this test to test padding bytes don't + * screw stuff up + * + * @param $file filename + * + * @dataProvider dataUtf8Comment + */ + public function testUtf8Comment( $file ) { + $res = JpegMetadataExtractor::segmentSplitter( $this->filePath . $file ); $this->assertEquals( array( 'UTF-8 JPEG Comment — ¼' ), $res['COM'] ); } + public function dataUtf8Comment() { + return array( + array( 'jpeg-comment-utf.jpg' ), + array( 'jpeg-padding-even.jpg' ), + array( 'jpeg-padding-odd.jpg' ), + ); + } /** The file is iso-8859-1, but it should get auto converted */ public function testIso88591Comment() { $res = JpegMetadataExtractor::segmentSplitter( $this->filePath . 'jpeg-comment-iso8859-1.jpg' );