You are here

public function CtoolsPageTokens::testReplaceVariableToken in Chaos Tool Suite (ctools) 7

Test that we can set page tokens.

File

tests/page_tokens.test, line 60
Tests for different parts of the ctools object caching system.

Class

CtoolsPageTokens
@file Tests for different parts of the ctools object caching system.

Code

public function testReplaceVariableToken() {
  $string = ctools_set_variable_token('title');
  $this
    ->assertEqual($string, '<!-- ctools-page-title -->', 'Expected form of token was found');
  $elements = array(
    '#type' => 'container',
    '#attributes' => array(
      'class' => array(
        'test',
      ),
    ),
    'title' => '<h2>Title</h2>',
    'content' => array(
      '#type' => 'markup',
      '#markup' => t('This is my test markup'),
      '#prefix' => $string,
    ),
    'link' => array(
      '#type' => 'link',
      '#title' => t('My link'),
      '#href' => 'node/1',
    ),
  );
  $markup = '<div class="test"><!-- ctools-page-title -->This is my test markup<a href="node/1">My link</a></div>';
  $new_markup = ctools_page_token_processing($markup, $elements);
  $this
    ->assertTrue(is_string($new_markup) && strlen($new_markup) > 1, 'Should return string');
  $this
    ->assertTrue(strstr($new_markup, '<h2>'), 'Variable Token Markup should contain h2 element');
  $this
    ->assertFalse(strstr($new_markup, 'ctools-page-title'), 'Variable Token Markup should not contain comment element');
}