예제 #1
0
 /**
  * Enables test mode
  *
  * It uses CFG->behat_dataroot
  *
  * Starts the test mode checking the composer installation and
  * the test environment and updating the available
  * features and steps definitions.
  *
  * Stores a file in dataroot/behat to allow Mahara to switch
  * to the test environment when using cli-server.
  * @throws MaharaBehatTestException
  * @return void
  */
 public static function start_test_mode()
 {
     global $CFG;
     if (!defined('BEHAT_UTIL')) {
         throw new MaharaBehatTestException('This method can be only used by Behat CLI tool');
     }
     // Checks the behat set up and the PHP version.
     if ($errorcode = BehatCommand::behat_setup_problem()) {
         exit($errorcode);
     }
     // Check that test environment is correctly set up.
     self::test_environment_problem();
     // Updates all the Mahara features and steps definitions.
     BehatConfigManager::update_config_file();
     if (self::is_test_mode_enabled()) {
         return;
     }
     $contents = '$CFG->behat_wwwroot, $CFG->behat_dbprefix and $CFG->behat_dataroot' . ' are currently used as $CFG->wwwroot, $CFG->dbprefix and $CFG->dataroot';
     $filepath = self::get_test_file_path();
     if (!file_put_contents($filepath, $contents)) {
         behat_error(BEHAT_EXITCODE_PERMISSIONS, 'File ' . $filepath . ' can not be created');
     }
 }
예제 #2
0
파일: util.php 프로젝트: rboyatt/mahara
$settings->options = $options;
$settings->info = 'CLI tool to manage Behat integration in Mahara';
$cli->setup($settings);
try {
    if ($cli->get_cli_param('install')) {
        BehatTestingUtil::install_site();
        cli::cli_exit("\nAcceptance test site is installed\n");
    } else {
        if ($cli->get_cli_param('drop')) {
            TestLock::acquire('behat');
            BehatTestingUtil::drop_site();
            cli::cli_exit("\nAcceptance tests site dropped\n");
        } else {
            if ($cli->get_cli_param('enable')) {
                BehatTestingUtil::start_test_mode();
                $runtestscommand = BehatCommand::get_behat_command(true) . ' --config ' . BehatConfigManager::get_behat_cli_config_filepath();
                cli::cli_exit("\nAcceptance tests environment enabled on {$CFG->behat_wwwroot}, to run the tests use:\n " . $runtestscommand . "\n");
            } else {
                if ($cli->get_cli_param('disable')) {
                    BehatTestingUtil::stop_test_mode();
                    cli::cli_exit("\nAcceptance test site is disabled\n");
                } else {
                    if ($cli->get_cli_param('diag')) {
                        $code = BehatTestingUtil::get_behat_status();
                        exit($code);
                    } else {
                        if ($cli->get_cli_param('config')) {
                            $code = BehatTestingUtil::get_behat_status();
                            if ($code == 0) {
                                echo BehatTestingUtil::get_behat_config_path();
                            }