(follow-up r100575 / r99477) unit-tests for jpegMetadataExtractor dealing with paddin...
authorBrian Wolff <bawolff@users.mediawiki.org>
Mon, 24 Oct 2011 02:47:22 +0000 (02:47 +0000)
committerBrian Wolff <bawolff@users.mediawiki.org>
Mon, 24 Oct 2011 02:47:22 +0000 (02:47 +0000)
tests/phpunit/data/media/README
tests/phpunit/data/media/jpeg-padding-even.jpg [new file with mode: 0644]
tests/phpunit/data/media/jpeg-padding-odd.jpg [new file with mode: 0644]
tests/phpunit/includes/media/JpegMetadataExtractorTest.php

index 2e2c565..fe3bc68 100644 (file)
@@ -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 (file)
index 0000000..c83c66b
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 (file)
index 0000000..25b9330
Binary files /dev/null and b/tests/phpunit/data/media/jpeg-padding-odd.jpg differ
index 2cfffdb..5bf9bfe 100644 (file)
@@ -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' );