function XmlrpcExampleTestCase::testXmlrpcExampleServer in Examples for Developers 6
Same name and namespace in other branches
- 7 xmlrpc_example/xmlrpc_example.test \XmlrpcExampleTestCase::testXmlrpcExampleServer()
Perform several xmlrpc requests changing server settings
File
- xmlrpc_example/
xmlrpc_example.test, line 70 - Test case for the xmlrpc example module.
Class
- XmlrpcExampleTestCase
- @file Test case for the xmlrpc example module.
Code
function testXmlrpcExampleServer() {
// Now test the UI.
$options = array(
'xmlrpc_example_server_min' => 3,
'xmlrpc_example_server_max' => 7,
);
$this
->drupalPost('examples/xmlrpc_server', $options, t('Save configuration'));
$this
->assertText(t("The configuration options have been saved"), t("Results limited to >= 3 and <= 7"));
$edit = array(
'num1' => 8,
'num2' => 3,
);
$this
->drupalPost('examples/xmlrpc_client', $edit, t('Subtract the integers'));
$this
->assertText(t("The XMLRPC server returned this response: @num", array(
'@num' => 5,
)));
$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(xmlrpc_errno(), 10002, t('subtracting 4-3 = 1 returns: 10002'));
$result = xmlrpc($this->xmlrpc_url, 'xmlrpc_example.add', 7, 4);
$this
->assertEqual(xmlrpc_errno(), 10001, t('Adding 7 + 4 = 11 returns: 10001'));
}