You are here

private function PageTitleTestCase::pageTitleCheck in Page Title 8.2

Same name and namespace in other branches
  1. 7.2 page_title.test \PageTitleTestCase::pageTitleCheck()
1 call to PageTitleTestCase::pageTitleCheck()
PageTitleTestCase::testPageTitleTest in ./page_title.test

File

./page_title.test, line 35
Test cases for the Page Title module.

Class

PageTitleTestCase
@file Test cases for the Page Title module.

Code

private function pageTitleCheck($path, $pattern, $tokens = array(), $section = '') {

  // Get the path...
  if (is_array($path)) {
    $this
      ->drupalGet($path['path'], $path['options']);
  }
  else {
    $this
      ->drupalGet($path);
  }

  // Apply tokens to pattern
  $title = strtr($pattern, $tokens);

  // Do some verbose output
  $this
    ->pass(t('Pattern: %pat', array(
    '%pat' => '<title>' . $pattern . '</title>',
  )));
  $this
    ->pass(t('Looking for title: %title', array(
    '%title' => '<title>' . $title . '</title>',
  )));

  // Look for the title in the content
  $res = $this
    ->assertRaw($title, t('Correct page title found in the <head> for: %section', array(
    '%section' => $section,
  )), 'Page Title');

  // If the search failed, do some more verbose debugging
  if (!$res) {
    preg_match('/<title>.*<\\/title>/', $this
      ->drupalGetContent(), $found_title);
    $this
      ->pass(t('Found instead: %found', array(
      '%found' => $found_title[0],
    )));
  }
}