diff --git a/admin/tool/behat/cli/init.php b/admin/tool/behat/cli/init.php index 5547b56eae3..8a3fa88602e 100644 --- a/admin/tool/behat/cli/init.php +++ b/admin/tool/behat/cli/init.php @@ -44,13 +44,19 @@ require_once(__DIR__ . '/../../../../lib/behat/lib.php'); chdir(__DIR__); $output = null; exec("php util.php --diag", $output, $code); + +// Ensure we have composer installed, before we install or re-install test site. +if ($code == BEHAT_EXITCODE_COMPOSER || $code == BEHAT_EXITCODE_INSTALL || $code == BEHAT_EXITCODE_REINSTALL) { + testing_update_composer_dependencies(); + chdir(__DIR__); + exec("php util.php --diag", $output, $code); +} + 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); @@ -60,8 +66,6 @@ if ($code == 0) { } else if ($code == BEHAT_EXITCODE_REINSTALL) { - testing_update_composer_dependencies(); - // Test site data is outdated. chdir(__DIR__); passthru("php util.php --drop", $code); @@ -74,18 +78,6 @@ if ($code == 0) { exit($code); } -} else if ($code == BEHAT_EXITCODE_COMPOSER) { - // Missing Behat dependencies. - - testing_update_composer_dependencies(); - - // Returning to admin/tool/behat/cli. - chdir(__DIR__); - passthru("php util.php --install", $code); - if ($code != 0) { - exit($code); - } - } else { // Generic error, we just output it. echo implode("\n", $output)."\n";