function WebTestBase::drupalGetXHR

Requests a Drupal path or an absolute path as if it is a XMLHttpRequest.

Parameters

\Drupal\Core\Url|string $path: Drupal path or URL to request from.

array $options: Array of URL options.

array $headers: Array of headers.

Return value

string The retrieved content.

1 call to WebTestBase::drupalGetXHR()
WebTestBase::drupalGetAjax in core/modules/simpletest/src/WebTestBase.php
Requests a path or URL in drupal_ajax format and JSON-decodes the response.

File

core/modules/simpletest/src/WebTestBase.php, line 882

Class

WebTestBase
Test case for typical Drupal tests.

Namespace

Drupal\simpletest

Code

protected function drupalGetXHR($path, array $options = [], array $headers = []) {
    $headers[] = 'X-Requested-With: XMLHttpRequest';
    return $this->drupalGet($path, $options, $headers);
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.