You are here

protected function BrowserTestBase::drupalGet in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 core/modules/simpletest/src/BrowserTestBase.php \Drupal\simpletest\BrowserTestBase::drupalGet()

Retrieves a Drupal path or an absolute path.

Parameters

string $path: Drupal path or URL to load into Mink controlled browser.

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

Return value

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

4 calls to BrowserTestBase::drupalGet()
BrowserTestBase::drupalLogin in core/modules/simpletest/src/BrowserTestBase.php
Logs in a user using the Mink controlled browser.
BrowserTestBase::drupalLogout in core/modules/simpletest/src/BrowserTestBase.php
Logs a user out of the Mink controlled browser and confirms.
BrowserTestBaseTest::testForm in core/modules/simpletest/tests/src/Functional/BrowserTestBaseTest.php
Tests basic form functionality.
BrowserTestBaseTest::testGoTo in core/modules/simpletest/tests/src/Functional/BrowserTestBaseTest.php
Tests basic page test.

File

core/modules/simpletest/src/BrowserTestBase.php, line 466
Contains \Drupal\simpletest\BrowserTestBase.

Class

BrowserTestBase
Provides a test case for functional Drupal tests.

Namespace

Drupal\simpletest

Code

protected function drupalGet($path, array $options = array()) {
  $options['absolute'] = TRUE;

  // The URL generator service is not necessarily available yet; e.g., in
  // interactive installer tests.
  if ($this->container
    ->has('url_generator')) {
    if (UrlHelper::isExternal($path)) {
      $url = Url::fromUri($path, $options)
        ->toString();
    }
    else {

      // This is needed for language prefixing.
      $options['path_processing'] = TRUE;
      $url = Url::fromUri('base:/' . $path, $options)
        ->toString();
    }
  }
  else {
    $url = $this
      ->getAbsoluteUrl($path);
  }
  $session = $this
    ->getSession();
  $this
    ->prepareRequest();
  $session
    ->visit($url);
  $out = $session
    ->getPage()
    ->getContent();

  // Ensure that any changes to variables in the other thread are picked up.
  $this
    ->refreshVariables();
  return $out;
}