Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Don't use PHPUnit's autoloader when the composer binary is used. #844

Merged
merged 1 commit into from

2 participants

@whatthejeff
Collaborator

This is related to a comment from 288bff7.

Some 3rd-party libraries (especially those providing custom test cases, printers, etc.) include calls to require_once('PHPUnit/Autoload.php');. This is obviously an issue if PHPUnit is installed via composer. This PR fixes that problem and provides a useful mechanism for library developers to accommodate for composer-based PHPUnit installs in the future.

@sebastianbergmann sebastianbergmann merged commit 605a5c0 into sebastianbergmann:3.7
@whatthejeff
Collaborator

We need to make this solution work for isolated tests as well.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
This page is out of date. Refresh to see the latest.
View
4 PHPUnit/Autoload.php
@@ -42,6 +42,10 @@
* @since File available since Release 3.5.0
*/
+if (defined('PHPUNIT_COMPOSER_INSTALL')) {
+ return;
+}
+
require_once 'File/Iterator/Autoload.php';
require_once 'PHP/CodeCoverage/Autoload.php';
require_once 'PHP/Timer/Autoload.php';
View
4 PHPUnit/Autoload.php.in
@@ -42,6 +42,10 @@
* @since File available since Release 3.5.0
*/
+if (defined('PHPUNIT_COMPOSER_INSTALL')) {
+ return;
+}
+
require_once 'File/Iterator/Autoload.php';
require_once 'PHP/CodeCoverage/Autoload.php';
require_once 'PHP/Timer/Autoload.php';
View
6 composer/bin/phpunit
@@ -42,19 +42,17 @@ $files = array(
__DIR__ . '/../../../../autoload.php'
);
-$found = FALSE;
-
foreach ($files as $file) {
if (file_exists($file)) {
require $file;
- $found = TRUE;
+ define('PHPUNIT_COMPOSER_INSTALL', TRUE);
break;
}
}
-if (!$found) {
+if (!defined('PHPUNIT_COMPOSER_INSTALL')) {
die(
'You need to set up the project dependencies using the following commands:' . PHP_EOL .
'curl -s http://getcomposer.org/installer | php' . PHP_EOL .
Something went wrong with that request. Please try again.