protected function XMLRPCMessagesTestCase::testAlterListMethods

7.x xmlrpc.test protected XMLRPCMessagesTestCase::testAlterListMethods()

Ensure that hook_xmlrpc_alter() can hide even builtin methods.

File

drupal-7.x/modules/simpletest/tests/xmlrpc.test, line 227

Class

XMLRPCMessagesTestCase

Code

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), 'Method list is altered by hook_xmlrpc_alter');
  $removed = reset($diff);
  $this->assertEqual($removed, 'system.methodSignature', 'Hiding builting system.methodSignature with hook_xmlrpc_alter works');
}