Skip to content

Commit

Permalink
MDL-37046 behat: Externalizations
Browse files Browse the repository at this point in the history
Instead of starting the PHP web server and calling
behat as a passthru we maintain them as standalone
  • Loading branch information
David Monllao committed Jan 29, 2013
1 parent 6d9427b commit 0b5f481
Show file tree
Hide file tree
Showing 4 changed files with 94 additions and 213 deletions.
47 changes: 15 additions & 32 deletions admin/tool/behat/cli/util.php
Expand Up @@ -15,7 +15,7 @@
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.

/**
* CLI tests runner
* CLI tool
*
* @package tool_behat
* @copyright 2012 David Monllaó
Expand All @@ -31,12 +31,9 @@
// CLI options.
list($options, $unrecognized) = cli_get_params(
array(
'help' => false,
'runtests' => false,
'tags' => false,
'extra' => '',
'with-javascript' => false,
'testenvironment' => false
'help' => false,
'enable' => false,
'disable' => false,
),
array(
'h' => 'help'
Expand All @@ -46,16 +43,14 @@
$help = "
Behat tool
Ensure the user who executes the action has permissions over behat installation
Options:
--runtests Runs the tests (accepts --with-javascript option, --tags=\"\" option to execute only the matching tests and --extra=\"\" to specify extra behat options)
--testenvironment Allows the test environment to be accesses through the built-in server (accepts value 'enable' or 'disable')
--enable Enables test environment
--disable Disables test environment
-h, --help Print out this help
Example from Moodle root directory:
\$ php admin/tool/behat/cli/util.php --runtests --tags=\"tool_behat\"
\$ php admin/tool/behat/cli/util.php --enable
More info in http://docs.moodle.org/dev/Acceptance_testing#Running_tests
";
Expand All @@ -70,29 +65,17 @@
cli_error(get_string('cliunknowoption', 'admin', $unrecognized));
}

$commands = array('runtests', 'testenvironment');
foreach ($commands as $command) {
if ($options[$command]) {
$action = $command;
}
}

if (empty($action)) {
mtrace('No command selected');
// Run command.
if ($options['enable']) {
$action = 'enable';
} else if ($options['disable']) {
$action = 'disable';
} else {
echo $help;
exit(0);
}

switch ($action) {

case 'runtests':
tool_behat::runtests($options['with-javascript'], $options['tags'], $options['extra']);
break;

case 'testenvironment':
tool_behat::switchenvironment($options['testenvironment']);
break;
}
tool_behat::switchenvironment($action);

mtrace(get_string('testenvironment' . $action, 'tool_behat'));

mtrace(get_string('finished', 'tool_behat'));
4 changes: 3 additions & 1 deletion admin/tool/behat/lang/en/tool_behat.php
Expand Up @@ -23,19 +23,21 @@
*/

$string['allavailablesteps'] = 'All the available steps';
$string['finished'] = 'Process finished';
$string['giveninfo'] = 'Given. Processes to set up the environment';
$string['installinfo'] = 'for installation and tests execution info';
$string['moreinfoin'] = 'More info in';
$string['newstepsinfo'] = 'for info about adding new steps definitions';
$string['newtestsinfo'] = 'for info about writting new tests';
$string['noaction'] = 'No action selected';
$string['nostepsdefinitions'] = 'There aren\'t steps definitions matching this filter';
$string['pluginname'] = 'Acceptance testing';
$string['phpunitenvproblem'] = 'PHPUnit environment problem';
$string['stepsdefinitionscomponent'] = 'Area';
$string['stepsdefinitionscontains'] = 'Contains';
$string['stepsdefinitionsfilters'] = 'Steps definitions';
$string['stepsdefinitionstype'] = 'Type';
$string['testenvironmentenable'] = 'Test environment enabled';
$string['testenvironmentdisable'] = 'Test environment disabled';
$string['theninfo'] = 'Then. Checkings to ensure the outcomes are the expected ones';
$string['viewsteps'] = 'Filter';
$string['wheninfo'] = 'When. Actions that provokes an event';
Expand Down

0 comments on commit 0b5f481

Please sign in to comment.