You are here

public function XmlRpcBasicTest::testAcceptHeaders in xmlrpc 8

Ensure that XML-RPC correctly handles XML Accept headers.

File

src/Tests/XmlRpcBasicTest.php, line 94

Class

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

Namespace

Drupal\xmlrpc\Tests

Code

public function testAcceptHeaders() {
  $request_header_sets = [
    // Default.
    'implicit' => [],
    'text/xml' => [
      'Accept' => 'text/xml',
    ],
    'application/xml' => [
      'Accept' => 'application/xml',
    ],
  ];
  foreach ($request_header_sets as $accept => $headers) {
    try {
      $methods = $this
        ->xmlRpcGet([
        'system.listMethods' => [],
      ], $headers);
      $this
        ->assertTrue(is_array($methods), strtr('@accept accept header is accepted', [
        '@accept' => $accept,
      ]));
    } catch (ClientException $e) {
      $this
        ->fail($e);
    }
  }
}