function WebTestBase::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()

28 calls to WebTestBase::drupalGet()
AggregatorTestBase::updateFeedItems in core/modules/aggregator/src/Tests/AggregatorTestBase.php
Updates the feed items.
BrowserTest::testGetAbsoluteUrl in core/modules/simpletest/src/Tests/BrowserTest.php
Test \Drupal\simpletest\WebTestBase::getAbsoluteUrl().
CommentTestBase::getUnapprovedComment in core/modules/comment/src/Tests/CommentTestBase.php
Gets the comment ID for an unapproved comment.
CommentTestBase::postComment in core/modules/comment/src/Tests/CommentTestBase.php
Posts a comment.
ContentTranslationUITestBase::doTestBasicTranslation in core/modules/content_translation/src/Tests/ContentTranslationUITestBase.php
Tests the basic translation workflow.

... See full list

1 method overrides WebTestBase::drupalGet()
UITestBase::drupalGet in core/modules/views_ui/src/Tests/UITestBase.php
Retrieves a Drupal path or an absolute path.

File

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

Class

WebTestBase
Test case for typical Drupal tests.

Namespace

Drupal\simpletest

Code

protected function drupalGet($path, array $options = [], array $headers = []) {
    // We re-using a CURL connection here. If that connection still has certain
    // options set, it might change the GET into a POST. Make sure we clear out
    // previous options.
    $out = $this->curlExec([
        CURLOPT_HTTPGET => TRUE,
        CURLOPT_URL => $this->buildUrl($path, $options),
        CURLOPT_NOBODY => FALSE,
        CURLOPT_HTTPHEADER => $headers,
    ]);
    // Ensure that any changes to variables in the other thread are picked up.
    $this->refreshVariables();
    // Replace original page output with new output from redirected page(s).
    if ($new = $this->checkForMetaRefresh()) {
        $out = $new;
        // We are finished with all meta refresh redirects, so reset the counter.
        $this->metaRefreshCount = 0;
    }
    if ($path instanceof Url) {
        $path = $path->setAbsolute()
            ->toString(TRUE)
            ->getGeneratedUrl();
    }
    $verbose = 'GET request to: ' . $path . '<hr />Ending URL: ' . $this->getUrl();
    if ($this->dumpHeaders) {
        $verbose .= '<hr />Headers: <pre>' . Html::escape(var_export(array_map('trim', $this->headers), TRUE)) . '</pre>';
    }
    $verbose .= '<hr />' . $out;
    $this->verbose($verbose);
    return $out;
}

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