jenkins-bot has submitted this change and it was merged.
Change subject: Support installing PHPUnit using composer.
......................................................................
Support installing PHPUnit using composer.
"phpunit/phpunit" already exists inside our composer.json's "require-dev"
however this has been
entirely useless as we don't include the autoloader which would load composer's
PHPUnit.
This change begins including composer's autoloader when present and also tweaks
phpunit.php
to ensure PHPUnit isn't double loaded. As a result besides supporting PHPUnit
via composer this
also means that we're ready to make use of any library we add to our
composer.json in the future.
Change-Id: I891740e8fd3d237c5f473862027205d951f564b9
---
M RELEASE-NOTES-1.22
M includes/WebStart.php
M maintenance/doMaintenance.php
M tests/phpunit/phpunit.php
4 files changed, 18 insertions(+), 3 deletions(-)
Approvals:
Parent5446: Looks good to me, approved
Jeroen De Dauw: Looks good to me, but someone else must approve
jenkins-bot: Verified
Daniel Friesen: Looks good to me, but someone else must approve
diff --git a/RELEASE-NOTES-1.22 b/RELEASE-NOTES-1.22
index 07763d9..e32d484 100644
--- a/RELEASE-NOTES-1.22
+++ b/RELEASE-NOTES-1.22
@@ -100,6 +100,7 @@
handlers can take further action based on the status of the patrol footer
* LinkCache singleton can now be altered or cleared, letting one to specify
another instance that does not rely on a database backend.
+* MediaWiki's PHPUnit tests can now use PHPUnit installed using composer --dev.
=== Bug fixes in 1.22 ===
* Disable Special:PasswordReset when $wgEnableEmail is false. Previously one
diff --git a/includes/WebStart.php b/includes/WebStart.php
index ead6d77..16658d3 100644
--- a/includes/WebStart.php
+++ b/includes/WebStart.php
@@ -91,6 +91,11 @@
}
}
+# Load composer's autoloader if present
+if ( is_readable( "$IP/vendor/autoload.php" ) ) {
+ require_once "$IP/vendor/autoload.php";
+}
+
# Get MWInit class
require_once "$IP/includes/Init.php";
diff --git a/maintenance/doMaintenance.php b/maintenance/doMaintenance.php
index 10984b0..866ec5a 100644
--- a/maintenance/doMaintenance.php
+++ b/maintenance/doMaintenance.php
@@ -53,9 +53,13 @@
// to $maintenance->mSelf. Keep that here for b/c
$self = $maintenance->getName();
-// Detect compiled mode
+# Load composer's autoloader if present
+if ( is_readable( "$IP/vendor/autoload.php" ) ) {
+ require_once "$IP/vendor/autoload.php";
+}
# Get the MWInit class
require_once "$IP/includes/Init.php";
+# Start the autoloader, so that extensions can derive classes from core files
require_once "$IP/includes/AutoLoader.php";
# Stub the profiler
require_once "$IP/includes/profiler/Profiler.php";
diff --git a/tests/phpunit/phpunit.php b/tests/phpunit/phpunit.php
index deef745..e4cb6b6 100755
--- a/tests/phpunit/phpunit.php
+++ b/tests/phpunit/phpunit.php
@@ -103,12 +103,17 @@
$maintClass = 'PHPUnitMaintClass';
require RUN_MAINTENANCE_IF_MAIN;
-require_once 'PHPUnit/Runner/Version.php';
+if ( !class_exists( 'PHPUnit_Runner_Version') ) {
+ require_once 'PHPUnit/Runner/Version.php';
+}
if ( PHPUnit_Runner_Version::id() !== '@package_version@'
&& version_compare( PHPUnit_Runner_Version::id(), '3.6.7', '<' )
) {
die( 'PHPUnit 3.6.7 or later required, you have ' .
PHPUnit_Runner_Version::id() . ".\n" );
}
-require_once 'PHPUnit/Autoload.php';
+
+if ( !class_exists( 'PHPUnit_TextUI_Command' ) ) {
+ require_once 'PHPUnit/Autoload.php';
+}
MediaWikiPHPUnitCommand::main();
--
To view, visit https://gerrit.wikimedia.org/r/66395
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I891740e8fd3d237c5f473862027205d951f564b9
Gerrit-PatchSet: 2
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: Daniel Friesen <[email protected]>
Gerrit-Reviewer: Daniel Friesen <[email protected]>
Gerrit-Reviewer: Demon <[email protected]>
Gerrit-Reviewer: Hashar <[email protected]>
Gerrit-Reviewer: Jeroen De Dauw <[email protected]>
Gerrit-Reviewer: Parent5446 <[email protected]>
Gerrit-Reviewer: Tobias Gritschacher <[email protected]>
Gerrit-Reviewer: jenkins-bot
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits