MDL-38878 behat: Also update composer dependencies after site install/reinstall

This commit is contained in:
David Monllao 2013-04-08 09:01:07 +08:00
parent 422f68fb86
commit 7b33327126
2 changed files with 48 additions and 13 deletions

View File

@ -41,14 +41,22 @@ if ($code == 0) {
echo "Behat test environment already installed\n";
} else if ($code == BEHAT_EXITCODE_INSTALL) {
testing_update_composer_dependencies();
// Behat and dependencies are installed and we need to install the test site.
chdir(__DIR__);
passthru("php util.php --install", $code);
if ($code != 0) {
exit($code);
}
} else if ($code == BEHAT_EXITCODE_REINSTALL) {
testing_update_composer_dependencies();
// Test site data is outdated.
chdir(__DIR__);
passthru("php util.php --drop", $code);
if ($code != 0) {
exit($code);
@ -62,19 +70,7 @@ if ($code == 0) {
} else if ($code == BEHAT_EXITCODE_COMPOSER) {
// Missing Behat dependencies.
// Changing to moodle dirroot to run composer related commands at project level.
chdir(__DIR__ . '/../../../..');
if (!file_exists(__DIR__ . '/../../../../composer.phar')) {
passthru("curl http://getcomposer.org/installer | php", $code);
if ($code != 0) {
exit($code);
}
}
passthru("php composer.phar update --dev", $code);
if ($code != 0) {
exit($code);
}
testing_update_composer_dependencies();
// Returning to admin/tool/behat/cli.
chdir(__DIR__);

View File

@ -128,3 +128,42 @@ function testing_error($errorcode, $text = '') {
echo($text."\n");
exit($errorcode);
}
/**
* Updates the composer installer and the dependencies.
*
* Includes --dev dependencies.
*
* @return void exit() if something goes wrong
*/
function testing_update_composer_dependencies() {
// To restore the value after finishing.
$cwd = getcwd();
// Dirroot.
chdir(__DIR__ . '/../..');
// Download composer.phar if we can.
if (!file_exists(__DIR__ . '/../../composer.phar')) {
passthru("curl http://getcomposer.org/installer | php", $code);
if ($code != 0) {
exit($code);
}
} else {
// If it is already there update the installer.
passthru("php composer.phar self-update", $code);
if ($code != 0) {
exit($code);
}
}
// Update composer dependencies.
passthru("php composer.phar update --dev", $code);
if ($code != 0) {
exit($code);
}
chdir($cwd);
}