function UiHelperTrait::checkForMetaRefresh

Same name in other branches
  1. 9 core/tests/Drupal/Tests/UiHelperTrait.php \Drupal\Tests\UiHelperTrait::checkForMetaRefresh()
  2. 8.9.x core/tests/Drupal/Tests/UiHelperTrait.php \Drupal\Tests\UiHelperTrait::checkForMetaRefresh()
  3. 10 core/tests/Drupal/Tests/UiHelperTrait.php \Drupal\Tests\UiHelperTrait::checkForMetaRefresh()

Checks for meta refresh tag and if found call drupalGet() recursively.

This function looks for the http-equiv attribute to be set to "Refresh" and is case-insensitive.

Return value

string|false Either the new page content or FALSE.

18 calls to UiHelperTrait::checkForMetaRefresh()
BigPipeTest::performMetaRefresh in core/modules/big_pipe/tests/src/Functional/BigPipeTest.php
Performs a single <meta> refresh explicitly.
BrowserTestBaseTest::testCheckForMetaRefresh in core/tests/Drupal/FunctionalTests/BrowserTestBaseTest.php
Tests the ::checkForMetaRefresh() method.
BrowserWithJavascriptTest::drupalGetWithAlert in core/tests/Drupal/FunctionalJavascriptTests/BrowserWithJavascriptTest.php
Retrieves a Drupal path or an absolute path.
EquivalentUpdateTest::testModuleUninstall in core/modules/system/tests/src/Functional/UpdateSystem/EquivalentUpdateTest.php
Tests that module uninstall removes skipped update information.
EquivalentUpdateTest::testUpdateHooks in core/modules/system/tests/src/Functional/UpdateSystem/EquivalentUpdateTest.php
Tests that update hooks are properly run.

... See full list

File

core/tests/Drupal/Tests/UiHelperTrait.php, line 484

Class

UiHelperTrait
Provides UI helper methods.

Namespace

Drupal\Tests

Code

protected function checkForMetaRefresh() {
    $refresh = $this->cssSelect('meta[http-equiv="Refresh"], meta[http-equiv="refresh"]');
    if (!empty($refresh) && (!isset($this->maximumMetaRefreshCount) || $this->metaRefreshCount < $this->maximumMetaRefreshCount)) {
        // Parse the content attribute of the meta tag for the format:
        // "[delay]: URL=[page_to_redirect_to]".
        if (preg_match('/\\d+;\\s*URL=\'?(?<url>[^\']*)/i', $refresh[0]->getAttribute('content'), $match)) {
            $this->metaRefreshCount++;
            return $this->drupalGet($this->getAbsoluteUrl(Html::decodeEntities($match['url'])));
        }
    }
    return FALSE;
}

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