Example #1
0
 /**
  * Generic field setter.
  *
  * Internal API method, a generic *I set "VALUE" to "FIELD" field*
  * could be created based on it.
  *
  * @param string $fieldlocator The pointer to the field, it will depend on the field type.
  * @param string $value
  * @return void
  */
 protected function set_field_value($fieldlocator, $value)
 {
     // We delegate to behat_form_field class, it will
     // guess the type properly as it is a select tag.
     $field = BehatFieldManager::get_form_field_from_label($fieldlocator, $this);
     $field->set_value($value);
 }
Example #2
0
 /**
  * Guesses the element type we are dealing with in case is not a text-based element.
  *
  * This class is the generic field type, BehatFieldManager::get_FormFields()
  * should be able to find the appropiate class for the field type, but
  * in cases like mahara form group elements we can not find the type of
  * the field through the DOM so we also need to take care of the
  * different field types from here. If we need to deal with more complex
  * mahara form elements we will need to refactor this simple HTML elements
  * guess method.
  *
  * @return BehatFormField
  */
 private function guess_type()
 {
     global $CFG;
     // We default to the text-based field if nothing was detected.
     if (!($type = BehatFieldManager::guess_field_type($this->field, $this->session))) {
         $type = 'text';
     }
     $classname = 'BehatForm' . ucfirst($type);
     $classpath = __DIR__ . '/' . $classname . '.php';
     require_once $classpath;
     return new $classname($this->session, $this->field);
 }