menu_example.test

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

Tests for menu example module.

Classes

NameDescription
MenuExampleTestCase@file Tests for menu example module.

File

menu_example/menu_example.test
View source
  1. <?php
  2. /**
  3. * @file
  4. * Tests for menu example module.
  5. */
  6. class MenuExampleTestCase extends DrupalWebTestCase {
  7. protected $web_user;
  8. public static function getInfo() {
  9. return array(
  10. 'name' => 'Menu example functionality',
  11. 'description' => 'Checks behavior of Menu Example.',
  12. 'group' => 'Examples',
  13. );
  14. }
  15. /**
  16. * Enable modules and create user with specific permissions.
  17. */
  18. public function setUp() {
  19. parent::setUp('menu_example');
  20. }
  21. /**
  22. * Test the various menus.
  23. */
  24. function testMenuExample() {
  25. $this->drupalGet('');
  26. $this->clickLink(t('Menu Example'));
  27. $this->assertText(t('This is the base page of the Menu Example'));
  28. $this->clickLink(t('Permissioned Example'));
  29. $this->assertText(t('Permissioned Example'));
  30. $this->clickLink('menu_example/permissioned/controlled');
  31. $this->assertResponse(403);
  32. $this->drupalGet('menu_example');
  33. $this->clickLink(t('MENU_CALLBACK example'));
  34. $this->drupalGet('menu_example/path_only/callback');
  35. $this->assertText(t('The menu entry for this page is of type MENU_CALLBACK'));
  36. $this->clickLink(t('Tabs'));
  37. $this->assertText(t('This is the "tabs" menu entry'));
  38. $this->drupalGet('menu_example/tabs/second');
  39. $this->assertText(t('This is the tab "second" in the "basic tabs" example'));
  40. $this->clickLink(t('third'));
  41. $this->assertText(t('This is the tab "third" in the "basic tabs" example'));
  42. $this->clickLink(t('Extra Arguments'));
  43. $this->drupalGet('menu_example/use_url_arguments/one/two');
  44. $this->assertText(t('Argument 1=one'));
  45. $this->clickLink(t('Placeholder Arguments'));
  46. $this->clickLink(t('menu_example/placeholder_argument/3343/display'));
  47. $this->assertRaw('<div>3343</div>');
  48. $this->clickLink(t('Processed Placeholder Arguments'));
  49. $this->assertText(t('Loaded value was jackpot! default'));
  50. // Create a user with permissions to access protected menu entry.
  51. $web_user = $this->drupalCreateUser(array('access protected menu example'));
  52. // Use custom overridden drupalLogin function to verify the user is logged
  53. // in.
  54. $this->drupalLogin($web_user);
  55. // Check that our title callback changing /user dynamically is working.
  56. // Using &#039; because of the format_username function.
  57. $this->assertRaw(t("@name&#039;s account", array('@name' => format_username($web_user))), t('Title successfully changed to account name: %name.', array('%name' => $web_user->name)));
  58. // Now start testing other menu entries.
  59. $this->drupalGet('menu_example');
  60. $this->clickLink(t('Permissioned Example'));
  61. $this->clickLink('menu_example/permissioned/controlled');
  62. $this->assertResponse(200);
  63. $this->assertText('This menu entry will not show');
  64. $this->drupalGet('menu_example/menu_altered_path');
  65. $this->assertText('This menu item was created strictly to allow the hook_menu_alter()');
  66. }
  67. }
Login or register to post comments