You are here

protected function UiHelperTrait::checkForMetaRefresh in Drupal 10

Same name and namespace in other branches
  1. 8 core/tests/Drupal/Tests/UiHelperTrait.php \Drupal\Tests\UiHelperTrait::checkForMetaRefresh()
  2. 9 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.

7 calls to UiHelperTrait::checkForMetaRefresh()
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.
UpdateSchemaTest::testUpdateHooks in core/modules/system/tests/src/Functional/UpdateSystem/UpdateSchemaTest.php
Tests that update hooks are properly run.
UpdateScriptTest::runUpdates in core/modules/system/tests/src/Functional/UpdateSystem/UpdateScriptTest.php
Helper function to run updates via the browser.
UpdateScriptTest::testRequirements in core/modules/system/tests/src/Functional/UpdateSystem/UpdateScriptTest.php
Tests that requirements warnings and errors are correctly displayed.

... See full list

File

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

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;
}