You are here

public function TokenBlockTestCase::testBlockTitleTokens in Token 7

File

./token.test, line 1078
Test integration for the token module.

Class

TokenBlockTestCase

Code

public function testBlockTitleTokens() {
  $edit['title'] = '[user:name]';
  $edit['info'] = 'Test token title block';
  $edit['body[value]'] = 'This is the test token title block.';
  $this
    ->drupalPost('admin/structure/block/add', $edit, 'Save block');

  // Ensure token validation is working on the block.
  $this
    ->assertText('Block title is using the following invalid tokens: [user:name].');

  // Create the block for real now with a valid title.
  $edit['title'] = '[current-page:title] block title';
  $edit['regions[bartik]'] = 'sidebar_first';
  $this
    ->drupalPost(NULL, $edit, 'Save block');
  $this
    ->drupalGet('node');
  $this
    ->assertText('Welcome to ' . variable_get('site_name', 'Drupal') . ' block title');

  // Ensure that tokens are not double-escaped when output as a block title.
  $node = $this
    ->drupalCreateNode(array(
    'title' => "Site's first node",
  ));
  $this
    ->drupalGet('node/' . $node->nid);

  // The apostraphe should only be escaped once via check_plain().
  $this
    ->assertRaw("Site's first node block title");
}