You are here

protected function UITestBase::drupalGet in Drupal 8

Same name in this branch
  1. 8 core/modules/views_ui/src/Tests/UITestBase.php \Drupal\views_ui\Tests\UITestBase::drupalGet()
  2. 8 core/modules/views_ui/tests/src/Functional/UITestBase.php \Drupal\Tests\views_ui\Functional\UITestBase::drupalGet()

Retrieves a Drupal path or an absolute path.

Parameters

\Drupal\Core\Url|string $path: Drupal path or URL to load into internal browser

$options: Options to be forwarded to the url generator.

$headers: An array containing additional HTTP request headers, each formatted as "name: value".

Return value

string The retrieved HTML string, also available as $this->getRawContent()

Overrides WebTestBase::drupalGet

File

core/modules/views_ui/src/Tests/UITestBase.php, line 84

Class

UITestBase
Provides a base class for testing the Views UI.

Namespace

Drupal\views_ui\Tests

Code

protected function drupalGet($path, array $options = [], array $headers = []) {
  $url = $this
    ->buildUrl($path, $options);

  // Ensure that each nojs page is accessible via ajax as well.
  if (strpos($url, 'nojs') !== FALSE) {
    $url = str_replace('nojs', 'ajax', $url);
    $result = $this
      ->drupalGet($url, $options, $headers);
    $this
      ->assertResponse(200);
    $this
      ->assertHeader('Content-Type', 'application/json');
    $this
      ->assertTrue(json_decode($result), 'Ensure that the AJAX request returned valid content.');
  }
  return parent::drupalGet($path, $options, $headers);
}