You are here

function ClientsConnectionDrupalRESTTestGeneric::testForm in Web Service Clients 7.3

Creates the form element for the test.

This gets a form element with the basics in place. If your test needs input parameters, add form elements here.

Parameters

$element: A form element for the test's settings and button.

Return value

The form element with the test's additions.

File

connections/clients_drupal_rest/clients_drupal_rest.testing.inc, line 305
Contains classes for Client connection testing.

Class

ClientsConnectionDrupalRESTTestGeneric
Test a generic REST request.

Code

function testForm($element) {
  $element['params']['method'] = array(
    '#type' => 'select',
    '#title' => t('Method'),
    '#options' => drupal_map_assoc(array(
      'GET',
      'POST',
      'PUT',
    )),
    '#required' => TRUE,
  );
  $entity_types = array_keys(entity_get_info());
  sort($entity_types);
  $entity_type_options = drupal_map_assoc($entity_types);
  $entity_type_options['_text'] = t('- Other -');
  $element['params']['entity'] = array(
    '#type' => 'select',
    '#title' => t('Entity type'),
    '#description' => t('The entity type to act on; i.e., the resource.'),
    '#options' => $entity_type_options,
    '#required' => FALSE,
  );
  $element['params']['entity_text'] = array(
    '#type' => 'textfield',
    '#title' => t('Entity type'),
    '#description' => t('The entity type to act on, if not in the list above.'),
    '#required' => FALSE,
  );
  $element['params']['entity_prefix'] = array(
    '#type' => 'checkbox',
    '#title' => t('Prefix entity type for Services Entity resource'),
    '#description' => t("Add the 'entity_' prefix to the entity type, for use with entity resources defined by Services Entity module."),
    '#required' => FALSE,
  );
  $element['params']['path'] = array(
    '#type' => 'textfield',
    '#title' => t('Path suffix'),
    '#description' => t('The remainder of the path, e.g., the entity ID, the entity ID and the action, etc.'),
  );
  $element['params']['data'] = array(
    '#type' => 'textarea',
    '#title' => t('Data'),
    '#description' => t('The POST or PUT data to pass, as a JSON array.'),
  );
  $element['params']['data_type'] = array(
    '#type' => 'radios',
    '#title' => t('Data type'),
    '#description' => t('The type of the data.'),
    '#options' => array(
      'json' => 'JSON',
      'php' => 'PHP array',
    ),
  );
  return $element;
}