function XmlrpcExampleTestCase::testXmlrpcExampleClient

Perform several calls using XML-RPC web client.

File

xmlrpc_example/xmlrpc_example.test, line 69

Class

XmlrpcExampleTestCase
Functional tests for the XMLRPC Example module.

Code

public function testXmlrpcExampleClient() {
  // Now test the UI.
  // Add the integers.
  $edit = array(
    'num1' => 3,
    'num2' => 5,
  );
  $this->drupalPost('examples/xmlrpc/client', $edit, t('Add the integers'));
  $this->assertText(t('The XML-RPC server returned this response: @num', array(
    '@num' => 8,
  )));
  // Subtract the integers.
  $edit = array(
    'num1' => 8,
    'num2' => 3,
  );
  $result = $this->drupalPost('examples/xmlrpc/client', $edit, t('Subtract the integers'));
  $this->assertText(t('The XML-RPC server returned this response: @num', array(
    '@num' => 5,
  )));
  // Request available methods.
  $this->drupalPost('examples/xmlrpc/client', $edit, t('Request methods'));
  $this->assertText('xmlrpc_example.add', 'The XML-RPC Add method was found.');
  $this->assertText('xmlrpc_example.subtract', 'The XML-RPC Subtract method was found.');
  // Before testing multicall, verify that method exists.
  $this->assertText('system.multicall', 'The XML-RPC Multicall method was found.');
  // Verify multicall request.
  $edit = array(
    'num1' => 5,
    'num2' => 2,
  );
  $this->drupalPost('examples/xmlrpc/client', $edit, t('Add and Subtract'));
  $this->assertText('[0] => 7', 'The XML-RPC server returned the addition result.');
  $this->assertText('[1] => 3', 'The XML-RPC server returned the subtraction result.');
}