MDL-49622 behat: better handling of profile and tags
authorEloy Lafuente (stronk7) <stronk7@moodle.org>
Sun, 22 Mar 2015 10:39:53 +0000 (11:39 +0100)
committerEloy Lafuente (stronk7) <stronk7@moodle.org>
Sun, 22 Mar 2015 10:39:53 +0000 (11:39 +0100)
This solves some minor annoyances in the run.php script:

A) profile is checked properly, independently of everything else.
B) cli tags get precedence over profile tags.

Indicentally, this also causes run.php to support both profile and
tag in command line together. Previously the use of profile did
invalidate the use of tags.

admin/tool/behat/cli/run.php

index 92c393c..4240747 100644 (file)
@@ -134,13 +134,19 @@ $tags = '';
 
 if ($options['profile']) {
     $profile = $options['profile'];
-    if (empty($CFG->behat_config[$profile]['filters']['tags'])) {
-        echo "Invaid profile passed: " . $profile;
+    if (!isset($CFG->behat_config[$profile])) {
+        echo "Invalid profile passed: " . $profile;
         exit(1);
     }
-    $tags = $CFG->behat_config[$profile]['filters']['tags'];
     $extraopts[] = '--profile=\'' . $profile . "'";
-} else if ($options['tags']) {
+    // By default, profile tags will be used.
+    if (!empty($CFG->behat_config[$profile]['filters']['tags'])) {
+        $tags = $CFG->behat_config[$profile]['filters']['tags'];
+    }
+}
+
+// Command line tags have precedence (std behat behavior).
+if ($options['tags']) {
     $tags = $options['tags'];
     $extraopts[] = '--tags="' . $tags . '"';
 }