[ Index ] |
PHP Cross Reference of moodle-2.8 |
[Summary view] [Print] [Text view]
1 <?php 2 // This file is part of Moodle - http://moodle.org/ 3 // 4 // Moodle is free software: you can redistribute it and/or modify 5 // it under the terms of the GNU General Public License as published by 6 // the Free Software Foundation, either version 3 of the License, or 7 // (at your option) any later version. 8 // 9 // Moodle is distributed in the hope that it will be useful, 10 // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 // GNU General Public License for more details. 13 // 14 // You should have received a copy of the GNU General Public License 15 // along with Moodle. If not, see <http://www.gnu.org/licenses/>. 16 17 /** 18 * CLI tool with utilities to manage Behat integration in Moodle 19 * 20 * All CLI utilities uses $CFG->behat_dataroot and $CFG->prefix_dataroot as 21 * $CFG->dataroot and $CFG->prefix 22 * 23 * @package tool_behat 24 * @copyright 2012 David Monllaó 25 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later 26 */ 27 28 29 if (isset($_SERVER['REMOTE_ADDR'])) { 30 die(); // No access from web!. 31 } 32 33 // Basic functions. 34 require_once (__DIR__ . '/../../../../lib/clilib.php'); 35 require_once (__DIR__ . '/../../../../lib/behat/lib.php'); 36 37 38 // CLI options. 39 list($options, $unrecognized) = cli_get_params( 40 array( 41 'help' => false, 42 'install' => false, 43 'drop' => false, 44 'enable' => false, 45 'disable' => false, 46 'diag' => false 47 ), 48 array( 49 'h' => 'help' 50 ) 51 ); 52 53 if ($options['install'] or $options['drop']) { 54 define('CACHE_DISABLE_ALL', true); 55 } 56 57 // Checking util.php CLI script usage. 58 $help = " 59 Behat utilities to manage the test environment 60 61 Options: 62 --install Installs the test environment for acceptance tests 63 --drop Drops the database tables and the dataroot contents 64 --enable Enables test environment and updates tests list 65 --disable Disables test environment 66 --diag Get behat test environment status code 67 68 -h, --help Print out this help 69 70 Example from Moodle root directory: 71 \$ php admin/tool/behat/cli/util.php --enable 72 73 More info in http://docs.moodle.org/dev/Acceptance_testing#Running_tests 74 "; 75 76 if (!empty($options['help'])) { 77 echo $help; 78 exit(0); 79 } 80 81 // Describe this script. 82 define('BEHAT_UTIL', true); 83 define('CLI_SCRIPT', true); 84 define('NO_OUTPUT_BUFFERING', true); 85 define('IGNORE_COMPONENT_CACHE', true); 86 87 // Only load CFG from config.php, stop ASAP in lib/setup.php. 88 define('ABORT_AFTER_CONFIG', true); 89 require_once(__DIR__ . '/../../../../config.php'); 90 91 // Remove error handling overrides done in config.php. 92 $CFG->debug = (E_ALL | E_STRICT); 93 $CFG->debugdisplay = 1; 94 error_reporting($CFG->debug); 95 ini_set('display_errors', '1'); 96 ini_set('log_errors', '1'); 97 98 // Finish moodle init. 99 define('ABORT_AFTER_CONFIG_CANCEL', true); 100 require("$CFG->dirroot/lib/setup.php"); 101 102 raise_memory_limit(MEMORY_HUGE); 103 104 require_once($CFG->libdir.'/adminlib.php'); 105 require_once($CFG->libdir.'/upgradelib.php'); 106 require_once($CFG->libdir.'/clilib.php'); 107 require_once($CFG->libdir.'/installlib.php'); 108 require_once($CFG->libdir.'/testing/classes/test_lock.php'); 109 110 if ($unrecognized) { 111 $unrecognized = implode("\n ", $unrecognized); 112 cli_error(get_string('cliunknowoption', 'admin', $unrecognized)); 113 } 114 115 // Behat utilities. 116 require_once($CFG->libdir . '/behat/classes/util.php'); 117 require_once($CFG->libdir . '/behat/classes/behat_command.php'); 118 119 // Run command (only one per time). 120 if ($options['install']) { 121 behat_util::install_site(); 122 mtrace("Acceptance tests site installed"); 123 } else if ($options['drop']) { 124 // Ensure no tests are running. 125 test_lock::acquire('behat'); 126 behat_util::drop_site(); 127 mtrace("Acceptance tests site dropped"); 128 } else if ($options['enable']) { 129 behat_util::start_test_mode(); 130 $runtestscommand = behat_command::get_behat_command(true) . 131 ' --config ' . behat_config_manager::get_behat_cli_config_filepath(); 132 mtrace("Acceptance tests environment enabled on $CFG->behat_wwwroot, to run the tests use:\n " . $runtestscommand); 133 } else if ($options['disable']) { 134 behat_util::stop_test_mode(); 135 mtrace("Acceptance tests environment disabled"); 136 } else if ($options['diag']) { 137 $code = behat_util::get_behat_status(); 138 exit($code); 139 } else { 140 echo $help; 141 } 142 143 exit(0);
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Fri Nov 28 20:29:05 2014 | Cross-referenced by PHPXref 0.7.1 |