MDL-80591 phpunit: delegate run to phpunit binary
Instead of manually including composer's auto-loading stuff and then run PHPUnit\TextUI\Command::main(), now we are using the PHPUnit "binary". That way behaviour should be 100% the same than running vendor/bin/phpunit (recommended instead of util.php --run). Also, note that, for other util.php commands, we still need composer's auto-loading to happen, so we have moved it immediately after the --run command. Finally, a few more file_exists() conditions have been added to ensure that PHPUnit is properly installed. Redundant but...
This commit is contained in:
@@ -50,12 +50,10 @@ list($options, $unrecognized) = cli_get_params(
|
||||
)
|
||||
);
|
||||
|
||||
if (file_exists(__DIR__.'/../../../../vendor/phpunit/phpunit/composer.json')) {
|
||||
// Composer packages present.
|
||||
require_once(__DIR__.'/../../../../vendor/autoload.php');
|
||||
|
||||
} else {
|
||||
// Note: installation via PEAR is not supported any more.
|
||||
// Basic check to see if phpunit is installed.
|
||||
if (!file_exists(__DIR__.'/../../../../vendor/phpunit/phpunit/composer.json') ||
|
||||
!file_exists(__DIR__.'/../../../../vendor/bin/phpunit') ||
|
||||
!file_exists(__DIR__.'/../../../../vendor/autoload.php')) {
|
||||
phpunit_bootstrap_error(PHPUNIT_EXITCODE_PHPUNITMISSING);
|
||||
}
|
||||
|
||||
@@ -74,12 +72,13 @@ if ($options['run']) {
|
||||
}
|
||||
}
|
||||
$_SERVER['argv'] = array_values($_SERVER['argv']);
|
||||
PHPUnit\TextUI\Command::main();
|
||||
require(__DIR__ . '/../../../../vendor/bin/phpunit');
|
||||
exit(0);
|
||||
}
|
||||
|
||||
define('PHPUNIT_UTIL', true);
|
||||
|
||||
require(__DIR__.'/../../../../vendor/autoload.php');
|
||||
require(__DIR__ . '/../../../../lib/phpunit/bootstrap.php');
|
||||
|
||||
// from now on this is a regular moodle CLI_SCRIPT
|
||||
|
||||
Reference in New Issue
Block a user