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()
Same name and namespace in other branches
  1. 9 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()

66 calls to UITestBase::drupalGet()
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
CachedDataUITest::testCacheData in core/modules/views_ui/tests/src/Functional/CachedDataUITest.php
Tests the shared tempstore views data in the UI.
ConfigTranslationViewListUiTest::testTranslateOperationInViewListUi in core/modules/config_translation/tests/src/Functional/ConfigTranslationViewListUiTest.php
Tests views_ui list to see if translate link is added to operations.
ContentTranslationViewsUITest::testViewsUI in core/modules/content_translation/tests/src/Functional/Views/ContentTranslationViewsUITest.php
Tests the views UI.

... See full list

File

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

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
      ->assertEquals('application/json', $this
      ->getSession()
      ->getResponseHeader('Content-Type'));
    $this
      ->assertNotEmpty(json_decode($result), 'Ensure that the AJAX request returned valid content.');
  }
  return parent::drupalGet($path, $options, $headers);
}