You are here

protected function DrupalWebTestCase::checkForMetaRefresh in SimpleTest 7

Same name and namespace in other branches
  1. 6.2 drupal_web_test_case.php \DrupalWebTestCase::checkForMetaRefresh()
  2. 7.2 drupal_web_test_case.php \DrupalWebTestCase::checkForMetaRefresh()

Check 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.

2 calls to DrupalWebTestCase::checkForMetaRefresh()
DrupalWebTestCase::drupalGet in ./drupal_web_test_case.php
Retrieves a Drupal path or an absolute path.
DrupalWebTestCase::drupalPost in ./drupal_web_test_case.php
Execute a POST request on a Drupal page. It will be done as usual POST request with SimpleBrowser.

File

./drupal_web_test_case.php, line 1516

Class

DrupalWebTestCase
Test case for typical Drupal tests.

Code

protected function checkForMetaRefresh() {
  if ($this
    ->drupalGetContent() != '' && $this
    ->parse()) {
    $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=(?P<url>.*)/i', $refresh[0]['content'], $match)) {
        return $this
          ->drupalGet($this
          ->getAbsoluteUrl(decode_entities($match['url'])));
      }
    }
  }
  return FALSE;
}