abstract class ClientsConnectionDrupalTestNodeLoadBase in Web Service Clients 7.3
Abstract base class for testing node load from a Drupal Services connection.
Hierarchy
- class \ClientsConnectionDrupalTestNodeLoadBase implements ClientsConnectionTestingInterface
Expanded class hierarchy of ClientsConnectionDrupalTestNodeLoadBase
File
- connections/
clients_drupal/ clients_drupal.testing.inc, line 119 - Contains classes for Client connection testing.
View source
abstract class ClientsConnectionDrupalTestNodeLoadBase implements ClientsConnectionTestingInterface {
/**
* The labels for the test.
*/
function testLabels() {
return array(
'label' => t('Test node retrieval'),
'description' => t('Load a node from the connection.'),
'button' => t('Load node'),
);
}
/**
* 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.
*
* @param $element
* A form element for the test's settings and button.
*
* @return
* The form element with the test's additions.
*/
function testForm($element) {
$element['params']['nid'] = array(
'#type' => 'textfield',
'#title' => t('Node ID'),
'#size' => 6,
'#required' => TRUE,
);
return $element;
}
/**
* Validate test form input.
*/
function formValidate(&$button_form_values) {
if (!is_numeric($button_form_values['params']['nid'])) {
form_set_error('buttons][node_load][nid', t('Node id must be numeric.'));
}
}
/**
* Execute the test.
*
* Connection test handlers should return the raw data they got back from the
* connection for display to the user.
*
* @param $connection
* The connection handler.
* @param $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
* Data from the remote connection. This is output to the form as raw data.
*/
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;
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
ClientsConnectionDrupalTestNodeLoadBase:: |
function | Validate test form input. | ||
ClientsConnectionDrupalTestNodeLoadBase:: |
function |
Execute the test. Overrides ClientsConnectionTestingInterface:: |
||
ClientsConnectionDrupalTestNodeLoadBase:: |
function | Creates the form element for the test. | ||
ClientsConnectionDrupalTestNodeLoadBase:: |
function |
The labels for the test. Overrides ClientsConnectionTestingInterface:: |