Commit 8ec91ce6 by Aaron Wells

Behat tests: Fixing composer up-to-date check

We were manually verifying the "hash" JSON field in external/composer.lock, but this was removed in Composer 1.3.0 Change-Id: If0862e0b63b6ee7d18f16ff393fba83a8653b2ba
parent 80ab4596
......@@ -72,10 +72,6 @@ class BehatCommand {
return BEHAT_EXITCODE_NOTINSTALLED;
}
if (!self::is_behat_updated()) {
return BEHAT_EXITCODE_NOTUPDATED;
}
// Run behat command.
list($output, $code) = self::run(' --help');
if ($code != 0) {
......@@ -97,24 +93,6 @@ class BehatCommand {
}
/**
* Returns TRUE if the composer lock file is up to date
* @return bool
*/
public static function is_behat_updated() {
$composerroot = get_composerroot_dir();
if (file_exists($composerroot.DIRECTORY_SEPARATOR.'composer.lock')
&& file_exists($composerroot.DIRECTORY_SEPARATOR.'composer.json')) {
$lock = json_decode(file_get_contents($composerroot.DIRECTORY_SEPARATOR.'composer.lock'))->hash;
$json = md5(file_get_contents($composerroot.DIRECTORY_SEPARATOR.'composer.json'));
if ($lock === $json) {
return true;
}
}
return false;
}
/**
* Outputs a message.
*
* Used in CLI + web UI methods. Stops the
......
......@@ -13,7 +13,7 @@
/**
* CLI tool to manage Behat integration in Mahara
*
* Like Moodle, This tool uses
* Like Moodle, This tool uses
* $CFG->behat_dataroot for $CFG->dataroot
* and $CFG->behat_dbprefix for $CFG->dbprefix
*/
......@@ -124,19 +124,24 @@ if ($statuscode == BEHAT_EXITCODE_CANNOTRUN) {
try {
if ($cli->get_cli_param('init')) {
// No need to init; already initialized.
if ($statuscode === 0) {
cli::cli_exit("The Behat test environment is already installed and active", 0);
}
cli::cli_print("Initializing the test site...");
if ($statuscode === BEHAT_EXITCODE_NOTINSTALLED) {
// Install behat and dependencies using composer
testing_install_dependencies();
}
else {
// Update behat and dependencies using composer
testing_update_dependencies();
}
// Other possible actions we may need to take.
switch ($statuscode) {
case 0:
cli::cli_exit("The Behat test environment is installed and enabled");
break;
case BEHAT_EXITCODE_NOTINSTALLED:
// Install behat and dependencies using composer
testing_install_dependencies();
break;
case BEHAT_EXITCODE_NOTUPDATED:
// Update behat and dependencies using composer
testing_update_dependencies();
break;
case BEHAT_MAHARA_EXITCODE_NOTINSTALLED:
BehatTestingUtil::install_site();
break;
......@@ -152,6 +157,8 @@ try {
behat_error($statuscode);
break;
}
// Now that all setup should be complete, start up test mode.
BehatTestingUtil::start_test_mode();
}
else if ($cli->get_cli_param('install')) {
......
......@@ -165,7 +165,7 @@ function testing_update_dependencies() {
if (file_exists($composerroot . '/composer.json')
&& file_exists($composerroot . '/composer.phar')
&& file_exists($composerroot . '/composer.lock')) {
echo "Updating composer dependencies...\n";
echo "Verifying that composer dependencies are up to date...\n";
passthru("php {$composerroot}/composer.phar update\
--working-dir={$composerroot}\
--no-interaction --quiet --no-dev", $errorcode);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment