You are here

protected function UITestBase::drupalGet in Drupal 9

Same name and namespace in other branches
  1. 8 core/modules/views_ui/tests/src/Functional/UITestBase.php \Drupal\Tests\views_ui\Functional\UITestBase::drupalGet()
  2. 10 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

string|\Drupal\Core\Url $path: Drupal path or URL to load into Mink controlled browser.

array $options: (optional) Options to be forwarded to the url generator.

string[] $headers: An array containing additional HTTP request headers, the array keys are the header names and the array values the header values. This is useful to set for example the "Accept-Language" header for requesting the page in a different language. Note that not all headers are supported, for example the "Accept" header is always overridden by the browser. For testing REST APIs it is recommended to obtain a separate HTTP client using getHttpClient() and performing requests that way.

Return value

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

Overrides UiHelperTrait::drupalGet

See also

\Drupal\Tests\BrowserTestBase::getHttpClient()

86 calls to UITestBase::drupalGet()
AccessRoleUITest::testAccessRoleUI in core/modules/user/tests/src/Functional/AccessRoleUITest.php
Tests the role access plugin UI.
AnalyzeTest::testAnalyzeBasic in core/modules/views_ui/tests/src/Functional/AnalyzeTest.php
Tests that analyze works in general.
AreaEntityUITest::testUI in core/modules/views_ui/tests/src/Functional/AreaEntityUITest.php
ArgumentValidatorTest::saveArgumentHandlerWithValidationOptions in core/modules/views_ui/tests/src/Functional/ArgumentValidatorTest.php
Saves the test_argument view with changes made to the argument handler both with and without specify_validation turned on.
CachedDataUITest::testCacheData in core/modules/views_ui/tests/src/Functional/CachedDataUITest.php
Tests the shared tempstore views data in the UI.

... See full list

File

core/modules/views_ui/tests/src/Functional/UITestBase.php, line 76

Class

UITestBase
Provides a base class for testing the Views UI.

Namespace

Drupal\Tests\views_ui\Functional

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 = preg_replace('|/nojs/|', '/ajax/', $url, 1);
    $result = $this
      ->drupalGet($url, $options);
    $this
      ->assertSession()
      ->statusCodeEquals(200);
    $this
      ->assertSession()
      ->responseHeaderEquals('Content-Type', 'application/json');
    $this
      ->assertNotEmpty(json_decode($result), 'Ensure that the AJAX request returned valid content.');
  }
  return parent::drupalGet($path, $options, $headers);
}