You are here

function ClientsConnectionDrupalTestNodeLoadBase::test in Web Service Clients 7.3

Execute the test.

Connection test handlers should return the raw data they got back from the connection for display to the user.

Parameters

$connection: The connection handler.

$button_form_values: The form values for the test form element. The values for elements added to the form are in $button_form_values['params'].

Return value

Data from the remote connection. This is output to the form as raw data.

Overrides ClientsConnectionTestingInterface::test

File

connections/clients_drupal/clients_drupal.testing.inc, line 179
Contains classes for Client connection testing.

Class

ClientsConnectionDrupalTestNodeLoadBase
Abstract base class for testing node load from a Drupal Services connection.

Code

function test($connection, &$button_form_values) {

  // Must be cast to integer for faffiness of XMLRPC and Services.
  $nid = (int) $button_form_values['params']['nid'];
  try {

    // The actual calling is taken care of in subclasses, to account for
    // differences in versions of Services.
    $node = $this
      ->callNodeLoadMethod($connection, $nid);
  } catch (Exception $e) {
    drupal_set_message(t('Could not retrieve a node from the remote site, got error message "@message".', array(
      '@message' => $e
        ->getMessage(),
    )), 'warning');

    //dsm($e);
    return;
  }
  if (is_array($node) && isset($node['nid'])) {
    drupal_set_message(t('Sucessfully retrieved node %title (nid @nid).', array(
      '%title' => $node['title'],
      '@nid' => $node['nid'],
    )));
  }
  return $node;
}