token_example.test

  1. examples
    1. 6 token_example/token_example.test
    2. 7 token_example/token_example.test
    3. 8 token_example/token_example.test

Test cases for Testing the token example module.

Classes

NameDescription
TokenExampleTestCase

File

token_example/token_example.test
View source
  1. <?php
  2. /**
  3. * @file
  4. * Test cases for Testing the token example module.
  5. */
  6. class TokenExampleTestCase extends DrupalWebTestCase {
  7. protected $web_user;
  8. public static function getInfo() {
  9. return array(
  10. 'name' => 'Token example functionality',
  11. 'description' => 'Verify the token example interface.',
  12. 'group' => 'Examples',
  13. 'dependencies' => array('token'),
  14. );
  15. }
  16. function setUp() {
  17. parent::setUp('token_example');
  18. $this->web_user = $this->drupalCreateUser();
  19. $this->drupalLogin($this->web_user);
  20. }
  21. function testInterface() {
  22. $filtered_id = db_query("SELECT format FROM {filter_format} WHERE name = 'Filtered HTML'")->fetchField();
  23. $default_format_id = filter_default_format($this->web_user);
  24. $this->drupalGet('examples/token');
  25. $this->assertNoFieldByName('node');
  26. $this->assertNoFieldByName('user');
  27. $edit = array(
  28. 'text' => 'User [current-user:name] is trying the token example!',
  29. );
  30. $this->drupalPost(NULL, $edit, t('Submit'));
  31. $this->assertText('User ' . $this->web_user->name . ' is trying the token example!');
  32. // Create a node and then make the 'Plain text' text format the default.
  33. $node = $this->drupalCreateNode(array('title' => 'Example node', 'status' => NODE_PUBLISHED));
  34. db_update('filter_format')
  35. ->fields(array('weight' => -10))
  36. ->condition('name', 'Plain text')
  37. ->execute();
  38. $this->drupalGet('examples/token');
  39. $edit = array(
  40. 'text' => 'Would you like to view the [node:type-name] [node:title] with text format [node:body-format] (ID [node:body-format:id])?',
  41. 'node' => $node->nid,
  42. );
  43. $this->drupalPost(NULL, $edit, t('Submit'));
  44. $this->assertText('Would you like to view the Basic page Example node with text format Filtered HTML (ID ' . $filtered_id . ')?');
  45. $edit = array(
  46. 'text' => 'Your default text format is [default-format:name] (ID [default-format:id]).',
  47. );
  48. $this->drupalPost(NULL, $edit, t('Submit'));
  49. $this->assertText('Your default text format is Filtered HTML (ID ' . $default_format_id . ')');
  50. }
  51. }
Login or register to post comments