'Token example functionality', 'description' => 'Verify the token example interface.', 'group' => 'Examples', 'dependencies' => array('token'), ); } function setUp() { parent::setUp('token_example'); $this->web_user = $this->drupalCreateUser(); $this->drupalLogin($this->web_user); } function testInterface() { $filtered_id = db_query("SELECT format FROM {filter_format} WHERE name = 'Filtered HTML'")->fetchField(); $plain_id = db_query("SELECT format FROM {filter_format} WHERE name = 'Plain text'")->fetchField(); $this->drupalGet('examples/token'); $this->assertNoFieldByName('node'); $this->assertNoFieldByName('user'); $edit = array( 'text' => 'User [current-user:name] is trying the token example!', ); $this->drupalPost(NULL, $edit, t('Submit')); $this->assertText('User ' . $this->web_user->name . ' is trying the token example!'); // Create a node and then make the 'Plain text' text format the default. $node = $this->drupalCreateNode(array('title' => 'Example node', 'status' => NODE_PUBLISHED)); db_update('filter_format') ->fields(array('weight' => -10)) ->condition('name', 'Plain text') ->execute(); $this->drupalGet('examples/token'); $this->assertFieldByName('node'); $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->drupalPost(NULL, $edit, t('Submit')); $this->assertText('Would you like to view the Basic 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->drupalPost(NULL, $edit, t('Submit')); $this->assertText('Your default text format is Plain text (ID ' . $plain_id . ')'); } }