You are here

function XmlrpcExampleTestCase::testXmlrpcExampleBasic in Examples for Developers 6

Same name and namespace in other branches
  1. 7 xmlrpc_example/xmlrpc_example.test \XmlrpcExampleTestCase::testXmlrpcExampleBasic()

Perform several calls the xmlrpc inteface to test the services.

File

xmlrpc_example/xmlrpc_example.test, line 36
Test case for the xmlrpc example module.

Class

XmlrpcExampleTestCase
@file Test case for the xmlrpc example module.

Code

function testXmlrpcExampleBasic() {

  // Unit test functionality.
  $result = xmlrpc($this->xmlrpc_url, 'xmlrpc_example.add', 3, 4);
  $this
    ->assertEqual($result, 7, t('Successfully added 3+4 = 7'));
  $result = xmlrpc($this->xmlrpc_url, 'xmlrpc_example.subtract', 4, 3);
  $this
    ->assertEqual($result, 1, t('Successfully subtracted 4-3 = 1'));

  // Verify default limits
  $result = xmlrpc($this->xmlrpc_url, 'xmlrpc_example.subtract', 3, 4);
  $this
    ->assertEqual(xmlrpc_errno(), 10002, t('Results below minimum return error: 10002'));
  $result = xmlrpc($this->xmlrpc_url, 'xmlrpc_example.add', 7, 4);
  $this
    ->assertEqual(xmlrpc_errno(), 10001, t('Results beyond maximum return error: 10001'));
}