diff --git a/admin/tool/behat/cli/util.php b/admin/tool/behat/cli/util.php index fe6dfc8c6db..93c5914d8b1 100644 --- a/admin/tool/behat/cli/util.php +++ b/admin/tool/behat/cli/util.php @@ -37,6 +37,7 @@ list($options, $unrecognized) = cli_get_params( 'filter' => false, 'tags' => false, 'extra' => false, + 'with-javascript' => false, 'testenvironment' => false ), array( @@ -51,13 +52,15 @@ Ensure the user who executes the action has permissions over behat installation Options: --stepsdefinitions Displays the available steps definitions (accepts --filter=\"\" option to restrict the list to the matching definitions) ---runtests Runs the tests (accepts --tags=\"\" option to execute only the matching tests and --extra=\"\" to specify extra behat 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') -h, --help Print out this help Example from Moodle root directory: \$ php admin/tool/behat/cli/util.php --runtests --tags=\"tool_behat\" + +More info in http://docs.moodle.org/dev/Acceptance_testing#Usage "; if (!empty($options['help'])) { @@ -90,7 +93,7 @@ switch ($action) { break; case 'runtests': - tool_behat::runtests($options['tags'], $options['extra']); + tool_behat::runtests($options['with-javascript'], $options['tags'], $options['extra']); break; case 'testenvironment': diff --git a/admin/tool/behat/locallib.php b/admin/tool/behat/locallib.php index 1037dc7dfc0..2b5cc767b1a 100644 --- a/admin/tool/behat/locallib.php +++ b/admin/tool/behat/locallib.php @@ -146,7 +146,7 @@ class tool_behat { * @param string $tags Restricts the executed tests to the ones that matches the tags * @param string $extra Extra CLI behat options */ - public static function runtests($tags = false, $extra = false) { + public static function runtests($withjavascript = false, $tags = false, $extra = false) { global $CFG; // Checks that the behat reference is properly set up @@ -159,14 +159,22 @@ class tool_behat { @set_time_limit(0); - // Priority to the one specified as argument. - if (!$tags) { - $tags = optional_param('tags', false, PARAM_ALPHANUMEXT); + // No javascript by default + if (!$withjavascript && strstr($tags, 'javascript') == false) { + $jsstr = '~javascript'; } + // Adding javascript option to --tags. $tagsoption = ''; if ($tags) { + if (!empty($jsstr)) { + $tags .= ',' . $jsstr; + } $tagsoption = ' --tags ' . $tags; + + // No javascript by default. + } else if (!empty($jsstr)) { + $tagsoption = ' --tags ' . $jsstr; } if (!$extra) {