7.x system.test PageTitleFiltering::testTitleTags()

Tests the handling of HTML by drupal_set_title() and drupal_get_title()


modules/system/system.test, line 1557
Tests for system.module.




function testTitleTags() {
  $title = "string with <em>HTML</em>";

  // drupal_set_title's $filter is CHECK_PLAIN by default, so the title should be
  // returned with check_plain().
  drupal_set_title($title, CHECK_PLAIN);
    ->assertTrue(strpos(drupal_get_title(), '<em>') === FALSE, 'Tags in title converted to entities when $output is CHECK_PLAIN.');

  // drupal_set_title's $filter is passed as PASS_THROUGH, so the title should be
  // returned with HTML.
  drupal_set_title($title, PASS_THROUGH);
    ->assertTrue(strpos(drupal_get_title(), '<em>') !== FALSE, 'Tags in title are not converted to entities when $output is PASS_THROUGH.');

  // Generate node content.
  $langcode = LANGUAGE_NONE;
  $edit = array(
    "title" => '!SimpleTest! ' . $title . $this
    "body[{$langcode}][0][value]" => '!SimpleTest! test body' . $this

  // Create the node with HTML in the title.
    ->drupalPost('node/add/page', $edit, t('Save'));
  $node = $this
    ->assertNotNull($node, 'Node created and found in database');
    ->drupalGet("node/" . $node->nid);
    ->assertText(check_plain($edit["title"]), 'Check to make sure tags in the node title are converted.');