From 8669bced5a62491f7b4a145a931913e0a4dab2a2 Mon Sep 17 00:00:00 2001 From: Kunal Mehta Date: Tue, 20 Sep 2016 20:20:10 -0700 Subject: [PATCH] Move XMP* classes to includes/libs These no longer have any dependencies upon MediaWiki and can be split out into a separate library. Tests were updated for the new location and to no longer depend upon MediaWikiTestCase. Bug: T100922 Change-Id: I6ad507fa883d5934b807f9e31c507659d0730b52 --- autoload.php | 6 +++--- includes/{media => libs/xmp}/XMP.php | 0 includes/{media => libs/xmp}/XMPInfo.php | 0 includes/{media => libs/xmp}/XMPValidate.php | 0 .../includes/{media => libs/xmp}/XMPTest.php | 17 ++++++++++------- .../{media => libs/xmp}/XMPValidateTest.php | 2 +- 6 files changed, 14 insertions(+), 11 deletions(-) rename includes/{media => libs/xmp}/XMP.php (100%) rename includes/{media => libs/xmp}/XMPInfo.php (100%) rename includes/{media => libs/xmp}/XMPValidate.php (100%) rename tests/phpunit/includes/{media => libs/xmp}/XMPTest.php (93%) rename tests/phpunit/includes/{media => libs/xmp}/XMPValidateTest.php (95%) diff --git a/autoload.php b/autoload.php index 198e477439..b6e0b8c75a 100644 --- a/autoload.php +++ b/autoload.php @@ -1561,9 +1561,9 @@ $wgAutoloadLocalClasses = [ 'XCFHandler' => __DIR__ . '/includes/media/XCF.php', 'XCacheBagOStuff' => __DIR__ . '/includes/libs/objectcache/XCacheBagOStuff.php', 'XMLRCFeedFormatter' => __DIR__ . '/includes/rcfeed/XMLRCFeedFormatter.php', - 'XMPInfo' => __DIR__ . '/includes/media/XMPInfo.php', - 'XMPReader' => __DIR__ . '/includes/media/XMP.php', - 'XMPValidate' => __DIR__ . '/includes/media/XMPValidate.php', + 'XMPInfo' => __DIR__ . '/includes/libs/xmp/XMPInfo.php', + 'XMPReader' => __DIR__ . '/includes/libs/xmp/XMP.php', + 'XMPValidate' => __DIR__ . '/includes/libs/xmp/XMPValidate.php', 'Xhprof' => __DIR__ . '/includes/libs/Xhprof.php', 'XhprofData' => __DIR__ . '/includes/libs/XhprofData.php', 'Xml' => __DIR__ . '/includes/Xml.php', diff --git a/includes/media/XMP.php b/includes/libs/xmp/XMP.php similarity index 100% rename from includes/media/XMP.php rename to includes/libs/xmp/XMP.php diff --git a/includes/media/XMPInfo.php b/includes/libs/xmp/XMPInfo.php similarity index 100% rename from includes/media/XMPInfo.php rename to includes/libs/xmp/XMPInfo.php diff --git a/includes/media/XMPValidate.php b/includes/libs/xmp/XMPValidate.php similarity index 100% rename from includes/media/XMPValidate.php rename to includes/libs/xmp/XMPValidate.php diff --git a/tests/phpunit/includes/media/XMPTest.php b/tests/phpunit/includes/libs/xmp/XMPTest.php similarity index 93% rename from tests/phpunit/includes/media/XMPTest.php rename to tests/phpunit/includes/libs/xmp/XMPTest.php index bffe415c5d..ac52a39ffe 100644 --- a/tests/phpunit/includes/media/XMPTest.php +++ b/tests/phpunit/includes/libs/xmp/XMPTest.php @@ -4,11 +4,14 @@ * @group Media * @covers XMPReader */ -class XMPTest extends MediaWikiTestCase { +class XMPTest extends PHPUnit_Framework_TestCase { protected function setUp() { parent::setUp(); - $this->checkPHPExtension( 'exif' ); # Requires libxml to do XMP parsing + # Requires libxml to do XMP parsing + if ( !extension_loaded( 'exif' ) ) { + $this->markTestSkipped( "PHP extension 'exif' is not loaded, skipping." ); + } } /** @@ -33,7 +36,7 @@ class XMPTest extends MediaWikiTestCase { } public static function provideXMPParse() { - $xmpPath = __DIR__ . '/../../data/xmp/'; + $xmpPath = __DIR__ . '/../../../data/xmp/'; $data = []; // $xmpFiles format: array of arrays with first arg file base name, @@ -86,7 +89,7 @@ class XMPTest extends MediaWikiTestCase { * @covers XMPReader::parseExtended */ public function testExtendedXMP() { - $xmpPath = __DIR__ . '/../../data/xmp/'; + $xmpPath = __DIR__ . '/../../../data/xmp/'; $standardXMP = file_get_contents( $xmpPath . 'xmpExt.xmp' ); $extendedXMP = file_get_contents( $xmpPath . 'xmpExt2.xmp' ); @@ -118,7 +121,7 @@ class XMPTest extends MediaWikiTestCase { * @covers XMPReader::parseExtended */ public function testExtendedXMPWithWrongGUID() { - $xmpPath = __DIR__ . '/../../data/xmp/'; + $xmpPath = __DIR__ . '/../../../data/xmp/'; $standardXMP = file_get_contents( $xmpPath . 'xmpExt.xmp' ); $extendedXMP = file_get_contents( $xmpPath . 'xmpExt2.xmp' ); @@ -149,7 +152,7 @@ class XMPTest extends MediaWikiTestCase { * @covers XMPReader::parseExtended */ public function testExtendedXMPMissingPacket() { - $xmpPath = __DIR__ . '/../../data/xmp/'; + $xmpPath = __DIR__ . '/../../../data/xmp/'; $standardXMP = file_get_contents( $xmpPath . 'xmpExt.xmp' ); $extendedXMP = file_get_contents( $xmpPath . 'xmpExt2.xmp' ); @@ -180,7 +183,7 @@ class XMPTest extends MediaWikiTestCase { public function testCheckParseSafety() { // Test for detection - $xmpPath = __DIR__ . '/../../data/xmp/'; + $xmpPath = __DIR__ . '/../../../data/xmp/'; $file = fopen( $xmpPath . 'doctype-included.xmp', 'rb' ); $valid = false; $reader = new XMPReader(); diff --git a/tests/phpunit/includes/media/XMPValidateTest.php b/tests/phpunit/includes/libs/xmp/XMPValidateTest.php similarity index 95% rename from tests/phpunit/includes/media/XMPValidateTest.php rename to tests/phpunit/includes/libs/xmp/XMPValidateTest.php index 6a006295df..7f7ea930e2 100644 --- a/tests/phpunit/includes/media/XMPValidateTest.php +++ b/tests/phpunit/includes/libs/xmp/XMPValidateTest.php @@ -5,7 +5,7 @@ use Psr\Log\NullLogger; /** * @group Media */ -class XMPValidateTest extends MediaWikiTestCase { +class XMPValidateTest extends PHPUnit_Framework_TestCase { /** * @dataProvider provideDates -- 2.20.1