MDL-55766 behat: set core behat selectors if not overridden by theme
authorRajesh Taneja <rajesh@moodle.com>
Tue, 30 Aug 2016 01:24:33 +0000 (09:24 +0800)
committerRajesh Taneja <rajesh@moodle.com>
Tue, 30 Aug 2016 23:23:13 +0000 (07:23 +0800)
lib/tests/behat/behat_hooks.php

index 017e342..5398e0a 100644 (file)
@@ -311,12 +311,16 @@ class behat_hooks extends behat_base {
             // We need the Mink session to do it and we do it only before the first scenario.
             $behatselectorclass = 'behat_selectors';
             if ($suitename !== 'default') {
-                $behatselectorclass = behat_config_util::get_behat_theme_selector_override_classname($suitename, true);
-            }
-            if (class_exists($behatselectorclass)) {
-                $behatselectorclass = new $behatselectorclass();
-                $behatselectorclass::register_moodle_selectors($session);
+                $overriddenselectorclass = behat_config_util::get_behat_theme_selector_override_classname($suitename, true);
+
+                // If override slector exist, then set it as default behat selectors class.
+                if (class_exists($overriddenselectorclass)) {
+                    $behatselectorclass = $overriddenselectorclass;
+                }
             }
+
+            $behatselectorclass = new $behatselectorclass();
+            $behatselectorclass::register_moodle_selectors($session);
         }
 
         // Reset mink session between the scenarios.