You are here

public function XmlRpcBasicTest::testInvalidMessageParsing in xmlrpc 8

Ensure that XML-RPC correctly handles invalid messages when parsing.

File

src/Tests/XmlRpcBasicTest.php, line 65

Class

XmlRpcBasicTest
Perform basic XML-RPC tests that do not require addition callbacks.

Namespace

Drupal\xmlrpc\Tests

Code

public function testInvalidMessageParsing() {
  module_load_include('inc', 'xmlrpc');
  $invalid_messages = [
    [
      'message' => xmlrpc_message(''),
      'assertion' => 'Empty message correctly rejected during parsing.',
    ],
    [
      'message' => xmlrpc_message('<?xml version="1.0" encoding="ISO-8859-1"?>'),
      'assertion' => 'Empty message with XML declaration correctly rejected during parsing.',
    ],
    [
      'message' => xmlrpc_message('<?xml version="1.0"?><params><param><value><string>value</string></value></param></params>'),
      'assertion' => 'Non-empty message without a valid message type is rejected during parsing.',
    ],
    [
      'message' => xmlrpc_message('<methodResponse><params><param><value><string>value</string></value></param></methodResponse>'),
      'assertion' => 'Non-empty malformed message is rejected during parsing.',
    ],
  ];
  foreach ($invalid_messages as $assertion) {
    $this
      ->assertFalse(xmlrpc_message_parse($assertion['message']), $assertion['assertion']);
  }
}