public function XmlRpcMessagesTest::testAlterListMethods in xmlrpc 8
Ensure that hook_xmlrpc_alter() can hide even builtin methods.
File
- src/
Tests/ XmlRpcMessagesTest.php, line 47
Class
- XmlRpcMessagesTest
- Tests large messages and method alterations.
Namespace
Drupal\xmlrpc\TestsCode
public function testAlterListMethods() {
// Ensure xmlrpc_test.alter() is disabled and retrieve regular list of
// methods.
\Drupal::state()
->set('xmlrpc_test.alter', FALSE);
$methods1 = $this
->xmlRpcGet([
'system.listMethods' => [],
]);
// Enable the alter hook and retrieve the list of methods again.
\Drupal::state()
->set('xmlrpc_test.alter', TRUE);
$methods2 = $this
->xmlRpcGet([
'system.listMethods' => [],
]);
$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 builtin system.methodSignature with hook_xmlrpc_alter works');
}