summaryrefslogtreecommitdiff
path: root/modules/simpletest
diff options
context:
space:
mode:
Diffstat (limited to 'modules/simpletest')
-rw-r--r--modules/simpletest/tests/xmlrpc.test25
-rw-r--r--modules/simpletest/tests/xmlrpc_test.module23
2 files changed, 46 insertions, 2 deletions
diff --git a/modules/simpletest/tests/xmlrpc.test b/modules/simpletest/tests/xmlrpc.test
index 7aad2be11..5069fe246 100644
--- a/modules/simpletest/tests/xmlrpc.test
+++ b/modules/simpletest/tests/xmlrpc.test
@@ -188,8 +188,8 @@ class XMLRPCValidator1IncTestCase extends DrupalWebTestCase {
class XMLRPCMessagesTestCase extends DrupalWebTestCase {
public static function getInfo() {
return array(
- 'name' => 'XML-RPC message',
- 'description' => 'Test large messages.',
+ 'name' => 'XML-RPC message and alteration',
+ 'description' => 'Test large messages and method alterations.',
'group' => 'XML-RPC',
);
}
@@ -211,4 +211,25 @@ class XMLRPCMessagesTestCase extends DrupalWebTestCase {
$this->assertEqual($xml_message_l, $xml_message_r, t('XML-RPC messages.messageSizedInKB of %s Kb size received', array('%s' => $size)));
}
}
+
+ /**
+ * Ensure that hook_xmlrpc_alter() can hide even builtin methods.
+ */
+ protected function testAlterListMethods() {
+
+ // Ensure xmlrpc_test_xmlrpc_alter() is disabled and retrieve regular list of methods.
+ variable_set('xmlrpc_test_xmlrpc_alter', FALSE);
+ $url = url(NULL, array('absolute' => TRUE)) . 'xmlrpc.php';
+ $methods1 = xmlrpc($url, array('system.listMethods' => array()));
+
+ // Enable the alter hook and retrieve the list of methods again.
+ variable_set('xmlrpc_test_xmlrpc_alter', TRUE);
+ $methods2 = xmlrpc($url, array('system.listMethods' => array()));
+
+ $diff = array_diff($methods1, $methods2);
+ $this->assertTrue(is_array($diff) && !empty($diff), t('Method list is altered by hook_xmlrpc_alter'));
+ $removed = reset($diff);
+ $this->assertEqual($removed, 'system.methodSignature', t('Hiding builting system.methodSignature with hook_xmlrpc_alter works'));
+ }
+
}
diff --git a/modules/simpletest/tests/xmlrpc_test.module b/modules/simpletest/tests/xmlrpc_test.module
index 9f06f48ae..f52afe325 100644
--- a/modules/simpletest/tests/xmlrpc_test.module
+++ b/modules/simpletest/tests/xmlrpc_test.module
@@ -64,6 +64,29 @@ function xmlrpc_test_xmlrpc() {
}
/**
+ * Implements hook_xmlrpc_alter().
+ *
+ * Hide (or not) the system.methodSignature() service depending on a variable.
+ */
+function xmlrpc_test_xmlrpc_alter(&$services) {
+ if (variable_get('xmlrpc_test_xmlrpc_alter', FALSE)) {
+ $remove = NULL;
+ foreach ($services as $key => $value) {
+ if (!is_array($value)) {
+ continue;
+ }
+ if ($value[0] == 'system.methodSignature') {
+ $remove = $key;
+ break;
+ }
+ }
+ if (isset($remove)) {
+ unset($services[$remove]);
+ }
+ }
+}
+
+/**
* Created a message of the desired size in KB.
*
* @param $size