1 system.test PageTitleFiltering::testTitleTags()

Tests the handling of HTML by backdrop_set_title() and backdrop_get_title()


core/modules/system/tests/system.test, line 1490
Tests for system.module.




function testTitleTags() {
  $title = "string with <em>HTML</em>";
  // backdrop_set_title's $filter is CHECK_PLAIN by default, so the title should be
  // returned with check_plain().
  backdrop_set_title($title, CHECK_PLAIN);
  $this->assertTrue(strpos(backdrop_get_title(), '<em>') === FALSE, 'Tags in title converted to entities when $output is CHECK_PLAIN.');
  // backdrop_set_title's $filter is passed as PASS_THROUGH, so the title should be
  // returned with HTML.
  backdrop_set_title($title, PASS_THROUGH);
  $this->assertTrue(strpos(backdrop_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->randomName(20),
    "body[$langcode][0][value]" => '!SimpleTest! test body' . $this->randomName(200),
  // Create the node with HTML in the title.
  $this->backdropPost('node/add/page', $edit, t('Save'));

  $node = $this->backdropGetNodeByTitle($edit["title"]);
  $this->assertNotNull($node, 'Node created and found in database');
  $this->backdropGet("node/" . $node->nid);
  $this->assertText(check_plain($edit["title"]), 'Check to make sure tags in the node title are converted.');