From a6623f7face6fe735980fbefca3df371f41d556e Mon Sep 17 00:00:00 2001 From: Brian Wolff Date: Wed, 17 Aug 2011 23:28:31 +0000 Subject: [PATCH] Move the image files used in the media tests from includes/media to data/media as the includes/media was starting to get crowded with supporting image files. This changes the following things *Moves the media files to a different directory *Changes the references to the files to reference there new locations 2 semi-unrelated changes *Modify the README file that was basically giving credit for the images where due to explain what the images are for. *set svn:mime-type to image/svg+xml for the svg files. --- .../{includes => data}/media/1bit-png.png | Bin ...imated_PNG_example_bouncing_beach_ball.png | Bin .../media/Gtk-media-play-ltr.svg | 0 .../media/Png-native-test.png | Bin .../{includes => data}/media/QA_icon.svg | 0 tests/phpunit/{includes => data}/media/README | 6 +- .../US_states_by_total_state_tax_revenue.svg | 0 .../media/Wikimedia-logo.svg | 0 .../media/Xmp-exif-multilingual_test.jpg | Bin .../media/broken_exif_date.jpg | Bin .../media/greyscale-na-png.png | Bin .../media/greyscale-png.png | Bin .../media/landscape-plain.jpg | Bin .../media/portrait-rotated.jpg | Bin .../{includes => data}/media/rgb-na-png.png | Bin .../{includes => data}/media/rgb-png.png | Bin .../phpunit/{includes => data}/media/test.jpg | Bin .../{includes => data}/media/test.tiff | Bin .../media/BitmapMetadataHandlerTest.php | 7 ++- .../includes/media/ExifRotationTest.php | 3 +- .../includes/media/FormatMetadataTest.php | 2 +- tests/phpunit/includes/media/JpegTest.php | 8 ++- .../media/PNGMetadataExtractorTest.php | 56 ++++++++++-------- .../media/SVGMetadataExtractorTest.php | 4 +- tests/phpunit/includes/media/TiffTest.php | 5 +- 25 files changed, 55 insertions(+), 36 deletions(-) rename tests/phpunit/{includes => data}/media/1bit-png.png (100%) rename tests/phpunit/{includes => data}/media/Animated_PNG_example_bouncing_beach_ball.png (100%) rename tests/phpunit/{includes => data}/media/Gtk-media-play-ltr.svg (100%) rename tests/phpunit/{includes => data}/media/Png-native-test.png (100%) rename tests/phpunit/{includes => data}/media/QA_icon.svg (100%) rename tests/phpunit/{includes => data}/media/README (91%) rename tests/phpunit/{includes => data}/media/US_states_by_total_state_tax_revenue.svg (100%) rename tests/phpunit/{includes => data}/media/Wikimedia-logo.svg (100%) rename tests/phpunit/{includes => data}/media/Xmp-exif-multilingual_test.jpg (100%) rename tests/phpunit/{includes => data}/media/broken_exif_date.jpg (100%) rename tests/phpunit/{includes => data}/media/greyscale-na-png.png (100%) rename tests/phpunit/{includes => data}/media/greyscale-png.png (100%) rename tests/phpunit/{includes => data}/media/landscape-plain.jpg (100%) rename tests/phpunit/{includes => data}/media/portrait-rotated.jpg (100%) rename tests/phpunit/{includes => data}/media/rgb-na-png.png (100%) rename tests/phpunit/{includes => data}/media/rgb-png.png (100%) rename tests/phpunit/{includes => data}/media/test.jpg (100%) rename tests/phpunit/{includes => data}/media/test.tiff (100%) diff --git a/tests/phpunit/includes/media/1bit-png.png b/tests/phpunit/data/media/1bit-png.png similarity index 100% rename from tests/phpunit/includes/media/1bit-png.png rename to tests/phpunit/data/media/1bit-png.png diff --git a/tests/phpunit/includes/media/Animated_PNG_example_bouncing_beach_ball.png b/tests/phpunit/data/media/Animated_PNG_example_bouncing_beach_ball.png similarity index 100% rename from tests/phpunit/includes/media/Animated_PNG_example_bouncing_beach_ball.png rename to tests/phpunit/data/media/Animated_PNG_example_bouncing_beach_ball.png diff --git a/tests/phpunit/includes/media/Gtk-media-play-ltr.svg b/tests/phpunit/data/media/Gtk-media-play-ltr.svg similarity index 100% rename from tests/phpunit/includes/media/Gtk-media-play-ltr.svg rename to tests/phpunit/data/media/Gtk-media-play-ltr.svg diff --git a/tests/phpunit/includes/media/Png-native-test.png b/tests/phpunit/data/media/Png-native-test.png similarity index 100% rename from tests/phpunit/includes/media/Png-native-test.png rename to tests/phpunit/data/media/Png-native-test.png diff --git a/tests/phpunit/includes/media/QA_icon.svg b/tests/phpunit/data/media/QA_icon.svg similarity index 100% rename from tests/phpunit/includes/media/QA_icon.svg rename to tests/phpunit/data/media/QA_icon.svg diff --git a/tests/phpunit/includes/media/README b/tests/phpunit/data/media/README similarity index 91% rename from tests/phpunit/includes/media/README rename to tests/phpunit/data/media/README index 7f638c1454..224db9acc4 100644 --- a/tests/phpunit/includes/media/README +++ b/tests/phpunit/data/media/README @@ -1,3 +1,8 @@ +This directory contains media files for use with the +tests in includes/media directory. + +Image credits: + QA_icon.svg: http://es.wikipedia.org/wiki/Archivo:QA_icon.svg GNU Lesser General Public License @@ -14,7 +19,6 @@ http://commons.wikimedia.org/wiki/File:US_states_by_total_state_tax_revenue.svg CC-BY 3.0 TastyCakes on English Wikipedia - greyscale-na-png.png, rgb-png.png, Xmp-exif-multilingual_test.jpg greyscale-png.png, 1bit-png.png, Png-native-test.png, rgb-na-png.png, test.tiff, test.jpg diff --git a/tests/phpunit/includes/media/US_states_by_total_state_tax_revenue.svg b/tests/phpunit/data/media/US_states_by_total_state_tax_revenue.svg similarity index 100% rename from tests/phpunit/includes/media/US_states_by_total_state_tax_revenue.svg rename to tests/phpunit/data/media/US_states_by_total_state_tax_revenue.svg diff --git a/tests/phpunit/includes/media/Wikimedia-logo.svg b/tests/phpunit/data/media/Wikimedia-logo.svg similarity index 100% rename from tests/phpunit/includes/media/Wikimedia-logo.svg rename to tests/phpunit/data/media/Wikimedia-logo.svg diff --git a/tests/phpunit/includes/media/Xmp-exif-multilingual_test.jpg b/tests/phpunit/data/media/Xmp-exif-multilingual_test.jpg similarity index 100% rename from tests/phpunit/includes/media/Xmp-exif-multilingual_test.jpg rename to tests/phpunit/data/media/Xmp-exif-multilingual_test.jpg diff --git a/tests/phpunit/includes/media/broken_exif_date.jpg b/tests/phpunit/data/media/broken_exif_date.jpg similarity index 100% rename from tests/phpunit/includes/media/broken_exif_date.jpg rename to tests/phpunit/data/media/broken_exif_date.jpg diff --git a/tests/phpunit/includes/media/greyscale-na-png.png b/tests/phpunit/data/media/greyscale-na-png.png similarity index 100% rename from tests/phpunit/includes/media/greyscale-na-png.png rename to tests/phpunit/data/media/greyscale-na-png.png diff --git a/tests/phpunit/includes/media/greyscale-png.png b/tests/phpunit/data/media/greyscale-png.png similarity index 100% rename from tests/phpunit/includes/media/greyscale-png.png rename to tests/phpunit/data/media/greyscale-png.png diff --git a/tests/phpunit/includes/media/landscape-plain.jpg b/tests/phpunit/data/media/landscape-plain.jpg similarity index 100% rename from tests/phpunit/includes/media/landscape-plain.jpg rename to tests/phpunit/data/media/landscape-plain.jpg diff --git a/tests/phpunit/includes/media/portrait-rotated.jpg b/tests/phpunit/data/media/portrait-rotated.jpg similarity index 100% rename from tests/phpunit/includes/media/portrait-rotated.jpg rename to tests/phpunit/data/media/portrait-rotated.jpg diff --git a/tests/phpunit/includes/media/rgb-na-png.png b/tests/phpunit/data/media/rgb-na-png.png similarity index 100% rename from tests/phpunit/includes/media/rgb-na-png.png rename to tests/phpunit/data/media/rgb-na-png.png diff --git a/tests/phpunit/includes/media/rgb-png.png b/tests/phpunit/data/media/rgb-png.png similarity index 100% rename from tests/phpunit/includes/media/rgb-png.png rename to tests/phpunit/data/media/rgb-png.png diff --git a/tests/phpunit/includes/media/test.jpg b/tests/phpunit/data/media/test.jpg similarity index 100% rename from tests/phpunit/includes/media/test.jpg rename to tests/phpunit/data/media/test.jpg diff --git a/tests/phpunit/includes/media/test.tiff b/tests/phpunit/data/media/test.tiff similarity index 100% rename from tests/phpunit/includes/media/test.tiff rename to tests/phpunit/data/media/test.tiff diff --git a/tests/phpunit/includes/media/BitmapMetadataHandlerTest.php b/tests/phpunit/includes/media/BitmapMetadataHandlerTest.php index d9424514ae..a587bbe54b 100644 --- a/tests/phpunit/includes/media/BitmapMetadataHandlerTest.php +++ b/tests/phpunit/includes/media/BitmapMetadataHandlerTest.php @@ -1,5 +1,10 @@ filePath = dirname( __FILE__ ) . '/../../data/media/'; + } + /** * Test if having conflicting metadata values from different * types of metadata, that the right one takes precedence. @@ -13,7 +18,7 @@ class BitmapMetadataHandlerTest extends MediaWikiTestCase { $this->markTestIncomplete( "This test needs the exif extension." ); } - $meta = BitmapMetadataHandler::Jpeg( dirname( __FILE__ ) . + $meta = BitmapMetadataHandler::Jpeg( $this->filePath . '/Xmp-exif-multilingual_test.jpg' ); $expected = array( diff --git a/tests/phpunit/includes/media/ExifRotationTest.php b/tests/phpunit/includes/media/ExifRotationTest.php index 1d4b7c513c..9d7f6b9ea9 100644 --- a/tests/phpunit/includes/media/ExifRotationTest.php +++ b/tests/phpunit/includes/media/ExifRotationTest.php @@ -7,6 +7,7 @@ class ExifRotationTest extends MediaWikiTestCase { function setUp() { parent::setUp(); + $this->filePath = dirname( __FILE__ ) . '/../../data/media/'; } /** @@ -17,7 +18,7 @@ class ExifRotationTest extends MediaWikiTestCase { $handler = new BitmapHandler(); # Force client side resizing $params = array( 'width' => 10000, 'height' => 10000 ); - $file = UnregisteredLocalFile::newFromPath( dirname( __FILE__ ) . '/' . $name, $type ); + $file = UnregisteredLocalFile::newFromPath( $this->filePath . $name, $type ); # Normalize parameters $this->assertTrue( $handler->normaliseParams( $file, $params ) ); diff --git a/tests/phpunit/includes/media/FormatMetadataTest.php b/tests/phpunit/includes/media/FormatMetadataTest.php index 57d5d6fcd5..159b53bf0c 100644 --- a/tests/phpunit/includes/media/FormatMetadataTest.php +++ b/tests/phpunit/includes/media/FormatMetadataTest.php @@ -6,7 +6,7 @@ class FormatMetadataTest extends MediaWikiTestCase { } $file = UnregisteredLocalFile::newFromPath( dirname( __FILE__ ) . - '/broken_exif_date.jpg', 'image/jpeg' ); + '/../../data/media/broken_exif_date.jpg', 'image/jpeg' ); // Throws an error if bug hit $meta = $file->formatMetadata(); diff --git a/tests/phpunit/includes/media/JpegTest.php b/tests/phpunit/includes/media/JpegTest.php index f0e37253ba..f31685c455 100644 --- a/tests/phpunit/includes/media/JpegTest.php +++ b/tests/phpunit/includes/media/JpegTest.php @@ -1,12 +1,16 @@ filePath = dirname( __FILE__ ) . '/../../data/media/'; + } + public function testInvalidFile() { if ( !wfDl( 'exif' ) ) { $this->markTestIncomplete( "This test needs the exif extension." ); } $jpeg = new JpegHandler; - $res = $jpeg->getMetadata( null, dirname( __FILE__ ) . '/README' ); + $res = $jpeg->getMetadata( null, $this->filePath . 'README' ); $this->assertEquals( ExifBitmapHandler::BROKEN_FILE, $res ); } public function testTiffFile() { @@ -14,7 +18,7 @@ class JpegTest extends MediaWikiTestCase { $this->markTestIncomplete( "This test needs the exif extension." ); } $h = new JpegHandler; - $res = $h->getMetadata( null, dirname( __FILE__ ) . '/test.jpg' ); + $res = $h->getMetadata( null, $this->filePath . 'test.jpg' ); $expected = 'a:7:{s:16:"ImageDescription";s:9:"Test file";s:11:"XResolution";s:4:"72/1";s:11:"YResolution";s:4:"72/1";s:14:"ResolutionUnit";i:2;s:16:"YCbCrPositioning";i:1;s:15:"JPEGFileComment";a:1:{i:0;s:17:"Created with GIMP";}s:22:"MEDIAWIKI_EXIF_VERSION";i:2;}'; // Unserialize in case serialization format ever changes. diff --git a/tests/phpunit/includes/media/PNGMetadataExtractorTest.php b/tests/phpunit/includes/media/PNGMetadataExtractorTest.php index db4e789d7e..1671a620d6 100644 --- a/tests/phpunit/includes/media/PNGMetadataExtractorTest.php +++ b/tests/phpunit/includes/media/PNGMetadataExtractorTest.php @@ -1,11 +1,15 @@ filePath = dirname( __FILE__ ) . '/../../data/media/'; + } /** * Tests zTXt tag (compressed textual metadata) */ function testPngNativetZtxt() { - $meta = PNGMetadataExtractor::getMetadata( dirname( __FILE__ ) . - '/Png-native-test.png' ); + $meta = PNGMetadataExtractor::getMetadata( $this->filePath . + 'Png-native-test.png' ); $expected = "foo bar baz foo foo foo foof foo foo foo foo"; $this->assertArrayHasKey( 'text', $meta ); $meta = $meta['text']; @@ -19,8 +23,8 @@ class PNGMetadataExtractorTest extends MediaWikiTestCase { * Test tEXt tag (Uncompressed textual metadata) */ function testPngNativeText() { - $meta = PNGMetadataExtractor::getMetadata( dirname( __FILE__ ) . - '/Png-native-test.png' ); + $meta = PNGMetadataExtractor::getMetadata( $this->filePath . + 'Png-native-test.png' ); $expected = "Some long image desc"; $this->assertArrayHasKey( 'text', $meta ); $meta = $meta['text']; @@ -36,8 +40,8 @@ class PNGMetadataExtractorTest extends MediaWikiTestCase { * Make sure non-ascii characters get converted properly */ function testPngNativeTextNonAscii() { - $meta = PNGMetadataExtractor::getMetadata( dirname( __FILE__ ) . - '/Png-native-test.png' ); + $meta = PNGMetadataExtractor::getMetadata( $this->filePath . + 'Png-native-test.png' ); // Note the Copyright symbol here is a utf-8 one // (aka \xC2\xA9) where in the file its iso-8859-1 @@ -57,8 +61,8 @@ class PNGMetadataExtractorTest extends MediaWikiTestCase { * Test extraction of pHYs tags, which can tell what the * actual resolution of the image is (aka in dots per meter). function testPngPhysTag () { - $meta = PNGMetadataExtractor::getMetadata( dirname( __FILE__ ) . - '/Png-native-test.png' ); + $meta = PNGMetadataExtractor::getMetadata( $this->filePath . + 'Png-native-test.png' ); $this->assertArrayHasKey( 'text', $meta ); $meta = $meta['text']; @@ -72,8 +76,8 @@ class PNGMetadataExtractorTest extends MediaWikiTestCase { * Given a normal static PNG, check the animation metadata returned. */ function testStaticPngAnimationMetadata() { - $meta = PNGMetadataExtractor::getMetadata( dirname( __FILE__ ) . - '/Png-native-test.png' ); + $meta = PNGMetadataExtractor::getMetadata( $this->filePath . + 'Png-native-test.png' ); $this->assertEquals( 0, $meta['frameCount'] ); $this->assertEquals( 1, $meta['loopCount'] ); @@ -85,8 +89,8 @@ class PNGMetadataExtractorTest extends MediaWikiTestCase { * check it gets animated metadata right. */ function testApngAnimationMetadata() { - $meta = PNGMetadataExtractor::getMetadata( dirname( __FILE__ ) . - '/Animated_PNG_example_bouncing_beach_ball.png' ); + $meta = PNGMetadataExtractor::getMetadata( $this->filePath . + 'Animated_PNG_example_bouncing_beach_ball.png' ); $this->assertEquals( 20, $meta['frameCount'] ); // Note loop count of 0 = infinity @@ -95,42 +99,42 @@ class PNGMetadataExtractorTest extends MediaWikiTestCase { } function testPngBitDepth8() { - $meta = PNGMetadataExtractor::getMetadata( dirname( __FILE__ ) . - '/Png-native-test.png' ); + $meta = PNGMetadataExtractor::getMetadata( $this->filePath . + 'Png-native-test.png' ); $this->assertEquals( 8, $meta['bitDepth'] ); } function testPngBitDepth1() { - $meta = PNGMetadataExtractor::getMetadata( dirname( __FILE__ ) . - '/1bit-png.png' ); + $meta = PNGMetadataExtractor::getMetadata( $this->filePath . + '1bit-png.png' ); $this->assertEquals( 1, $meta['bitDepth'] ); } function testPngIndexColour() { - $meta = PNGMetadataExtractor::getMetadata( dirname( __FILE__ ) . - '/Png-native-test.png' ); + $meta = PNGMetadataExtractor::getMetadata( $this->filePath . + 'Png-native-test.png' ); $this->assertEquals( 'index-coloured', $meta['colorType'] ); } function testPngRgbColour() { - $meta = PNGMetadataExtractor::getMetadata( dirname( __FILE__ ) . - '/rgb-png.png' ); + $meta = PNGMetadataExtractor::getMetadata( $this->filePath . + 'rgb-png.png' ); $this->assertEquals( 'truecolour-alpha', $meta['colorType'] ); } function testPngRgbNoAlphaColour() { - $meta = PNGMetadataExtractor::getMetadata( dirname( __FILE__ ) . - '/rgb-na-png.png' ); + $meta = PNGMetadataExtractor::getMetadata( $this->filePath . + 'rgb-na-png.png' ); $this->assertEquals( 'truecolour', $meta['colorType'] ); } function testPngGreyscaleColour() { - $meta = PNGMetadataExtractor::getMetadata( dirname( __FILE__ ) . - '/greyscale-png.png' ); + $meta = PNGMetadataExtractor::getMetadata( $this->filePath . + 'greyscale-png.png' ); $this->assertEquals( 'greyscale-alpha', $meta['colorType'] ); } function testPngGreyscaleNoAlphaColour() { - $meta = PNGMetadataExtractor::getMetadata( dirname( __FILE__ ) . - '/greyscale-na-png.png' ); + $meta = PNGMetadataExtractor::getMetadata( $this->filePath . + 'greyscale-na-png.png' ); $this->assertEquals( 'greyscale', $meta['colorType'] ); } diff --git a/tests/phpunit/includes/media/SVGMetadataExtractorTest.php b/tests/phpunit/includes/media/SVGMetadataExtractorTest.php index 6979ed017e..c2c81b982b 100644 --- a/tests/phpunit/includes/media/SVGMetadataExtractorTest.php +++ b/tests/phpunit/includes/media/SVGMetadataExtractorTest.php @@ -39,7 +39,7 @@ class SVGMetadataExtractorTest extends MediaWikiTestCase { } function providerSvgFiles() { - $base = dirname( __FILE__ ); + $base = dirname( __FILE__ ) . '/../../data/media'; return array( array( "$base/Wikimedia-logo.svg", @@ -66,7 +66,7 @@ class SVGMetadataExtractorTest extends MediaWikiTestCase { } function providerSvgFilesWithXMLMetadata() { - $base = dirname( __FILE__ ); + $base = dirname( __FILE__ ) . '/../../data/media'; return array( array( "$base/US_states_by_total_state_tax_revenue.svg", diff --git a/tests/phpunit/includes/media/TiffTest.php b/tests/phpunit/includes/media/TiffTest.php index cb62ebbe93..3a6dc356ec 100644 --- a/tests/phpunit/includes/media/TiffTest.php +++ b/tests/phpunit/includes/media/TiffTest.php @@ -5,6 +5,7 @@ class TiffTest extends MediaWikiTestCase { global $wgShowEXIF; $this->showExif = $wgShowEXIF; $wgShowEXIF = true; + $this->filePath = dirname( __FILE__ ) . '/../../data/media/'; } public function tearDown() { @@ -17,7 +18,7 @@ class TiffTest extends MediaWikiTestCase { $this->markTestIncomplete( "This test needs the exif extension." ); } $tiff = new TiffHandler; - $res = $tiff->getMetadata( null, dirname( __FILE__ ) . '/README' ); + $res = $tiff->getMetadata( null, $this->filePath . 'README' ); $this->assertEquals( ExifBitmapHandler::BROKEN_FILE, $res ); } @@ -26,7 +27,7 @@ class TiffTest extends MediaWikiTestCase { $this->markTestIncomplete( "This test needs the exif extension." ); } $tiff = new TiffHandler; - $res = $tiff->getMetadata( null, dirname( __FILE__ ) . '/test.tiff' ); + $res = $tiff->getMetadata( null, $this->filePath . 'test.tiff' ); $expected = 'a:16:{s:10:"ImageWidth";i:20;s:11:"ImageLength";i:20;s:13:"BitsPerSample";a:3:{i:0;i:8;i:1;i:8;i:2;i:8;}s:11:"Compression";i:5;s:25:"PhotometricInterpretation";i:2;s:16:"ImageDescription";s:17:"Created with GIMP";s:12:"StripOffsets";i:8;s:11:"Orientation";i:1;s:15:"SamplesPerPixel";i:3;s:12:"RowsPerStrip";i:64;s:15:"StripByteCounts";i:238;s:11:"XResolution";s:19:"1207959552/16777216";s:11:"YResolution";s:19:"1207959552/16777216";s:19:"PlanarConfiguration";i:1;s:14:"ResolutionUnit";i:2;s:22:"MEDIAWIKI_EXIF_VERSION";i:2;}'; // Re-unserialize in case there are subtle differences between how versions // of php serialize stuff. -- 2.20.1