You are here

protected function WebTestBase::checkForMetaRefresh in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 core/modules/simpletest/src/WebTestBase.php \Drupal\simpletest\WebTestBase::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-sensitive.

Return value

Either the new page content or FALSE.

3 calls to WebTestBase::checkForMetaRefresh()
AddFeedTest::testFeedLabelEscaping in core/modules/aggregator/src/Tests/AddFeedTest.php
Ensures that the feed label is escaping when rendering the feed icon.
WebTestBase::drupalGet in core/modules/simpletest/src/WebTestBase.php
Retrieves a Drupal path or an absolute path.
WebTestBase::drupalPostForm in core/modules/simpletest/src/WebTestBase.php
Executes a form submission.

File

core/modules/simpletest/src/WebTestBase.php, line 2216
Contains \Drupal\simpletest\WebTestBase.

Class

WebTestBase
Test case for typical Drupal tests.

Namespace

Drupal\simpletest

Code

protected function checkForMetaRefresh() {
  if (strpos($this
    ->getRawContent(), '<meta ') && $this
    ->parse() && (!isset($this->maximumMetaRefreshCount) || $this->metaRefreshCount < $this->maximumMetaRefreshCount)) {
    $refresh = $this
      ->xpath('//meta[@http-equiv="Refresh"]');
    if (!empty($refresh)) {

      // 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]['content'], $match)) {
        $this->metaRefreshCount++;
        return $this
          ->drupalGet($this
          ->getAbsoluteUrl(Html::decodeEntities($match['url'])));
      }
    }
  }
  return FALSE;
}