Example #1
0
 /**
  * Parse $CFG->behat_config and return the array with required config structure for behat.yml
  *
  * @param string $profile profile name
  * @param array $values values for profile
  * @return array
  */
 public function get_behat_config_for_profile($profile, $values)
 {
     // Only add profile which are compatible with Behat 3.x
     // Just check if any of Bheat 2.5 config is set. Not checking for 3.x as it might have some other configs
     // Like : rerun_cache etc.
     if (!isset($values['filters']['tags']) && !isset($values['extensions']['Behat\\MinkExtension\\Extension'])) {
         return array($profile => $values);
     }
     // Parse 2.5 format and get related values.
     $oldconfigvalues = array();
     if (isset($values['extensions']['Behat\\MinkExtension\\Extension'])) {
         $extensionvalues = $values['extensions']['Behat\\MinkExtension\\Extension'];
         if (isset($extensionvalues['selenium2']['browser'])) {
             $oldconfigvalues['browser'] = $extensionvalues['selenium2']['browser'];
         }
         if (isset($extensionvalues['selenium2']['wd_host'])) {
             $oldconfigvalues['wd_host'] = $extensionvalues['selenium2']['wd_host'];
         }
         if (isset($extensionvalues['capabilities'])) {
             $oldconfigvalues['capabilities'] = $extensionvalues['capabilities'];
         }
     }
     if (isset($values['filters']['tags'])) {
         $oldconfigvalues['tags'] = $values['filters']['tags'];
     }
     if (!empty($oldconfigvalues)) {
         behat_config_manager::$autoprofileconversion = true;
         return $this->get_behat_profile($profile, $oldconfigvalues);
     }
     // If nothing set above then return empty array.
     return array();
 }