public function XmlrpcExampleTestCase::testXmlrpcExampleBasic in Examples for Developers 7
Same name and namespace in other branches
- 6 xmlrpc_example/xmlrpc_example.test \XmlrpcExampleTestCase::testXmlrpcExampleBasic()
Perform several calls to the XML-RPC interface to test the services.
File
- xmlrpc_example/
xmlrpc_example.test, line 41 - Test case for the XML-RPC example module.
Class
- XmlrpcExampleTestCase
- Functional tests for the XMLRPC Example module.
Code
public function testXmlrpcExampleBasic() {
// Unit test functionality.
$result = xmlrpc($this->xmlRpcUrl, array(
'xmlrpc_example.add' => array(
3,
4,
),
));
$this
->assertEqual($result, 7, 'Successfully added 3+4 = 7');
$result = xmlrpc($this->xmlRpcUrl, array(
'xmlrpc_example.subtract' => array(
4,
3,
),
));
$this
->assertEqual($result, 1, 'Successfully subtracted 4-3 = 1');
// Make a multicall request.
$options = array(
'xmlrpc_example.add' => array(
5,
2,
),
'xmlrpc_example.subtract' => array(
5,
2,
),
);
$expected = array(
7,
3,
);
$result = xmlrpc($this->xmlRpcUrl, $options);
$this
->assertEqual($result, $expected, 'Successfully called multicall request');
// Verify default limits.
$result = xmlrpc($this->xmlRpcUrl, array(
'xmlrpc_example.subtract' => array(
3,
4,
),
));
$this
->assertEqual(xmlrpc_errno(), 10002, 'Results below minimum return custom error: 10002');
$result = xmlrpc($this->xmlRpcUrl, array(
'xmlrpc_example.add' => array(
7,
4,
),
));
$this
->assertEqual(xmlrpc_errno(), 10001, 'Results beyond maximum return custom error: 10001');
}