1 token_example.test public TokenExampleTestCase::testInterface()

Test interface.

File

modules/examples/token_example/tests/token_example.test, line 28
Test cases for Testing the token example module.

Class

TokenExampleTestCase
Functional tests for the Token Example module.

Code

public function testInterface() {
  $filtered_id = config_get('filter.format.filtered_html', 'format');
  $default_format_id = filter_default_format($this->webUser);

  $this->backdropGet('examples/token');
  $this->assertFieldByName('node');
  $this->assertNoFieldByName('user');

  $edit = array(
    'text' => 'User [current-user:name] is trying the token example!',
  );
  $this->backdropPost(NULL, $edit, t('Submit'));
  $this->assertText('User ' . $this->webUser->name . ' is trying the token example!');

  // Create a node and then make the 'Plain text' text format the default.
  $node = $this->backdropCreateNode(array('title' => 'Example node', 'status' => NODE_PUBLISHED));
  config_set('filter.format.plain_text', 'weight', -10);

  $this->backdropGet('examples/token');

  $edit = array(
    'text' => 'Would you like to view the [node:type-name] [node:title] with text format [node:body-format] (ID [node:body-format:id])?',
    'node' => $node->nid,
  );
  $this->backdropPost(NULL, $edit, t('Submit'));
  $this->assertText('Would you like to view the Page Example node with text format Filtered HTML (ID ' . $filtered_id . ')?');

  $edit = array(
    'text' => 'Your default text format is [default-format:name] (ID [default-format:id]).',
  );
  $this->backdropPost(NULL, $edit, t('Submit'));
  $this->assertText('Your default text format is Filtered HTML (ID ' . $default_format_id . ')');
}