extlink.test 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. <?php
  2. /**
  3. * @file
  4. * External Link tests.
  5. */
  6. /**
  7. * Base class for External Link tests.
  8. *
  9. * Provides common setup stuff and various helper functions.
  10. */
  11. class ExtlinkBaseWebTestCase extends DrupalWebTestCase {
  12. /**
  13. * User with various administrative permissions.
  14. *
  15. * @var Drupaluser
  16. */
  17. protected $adminUser;
  18. /**
  19. * Normal visitor with limited permissions.
  20. *
  21. * @var Drupaluser
  22. */
  23. protected $normalUser;
  24. /**
  25. * Drupal path of the (general) External Links admin page.
  26. */
  27. const EXTLINK_ADMIN_PATH = 'admin/config/user-interface/extlink';
  28. /**
  29. * Set up tests.
  30. */
  31. public function setUp() {
  32. // Enable any module that you will need in your tests.
  33. parent::setUp('extlink');
  34. // Create a normal user.
  35. $permissions = array(
  36. 'access comments', 'post comments', 'skip comment approval',
  37. 'access content', 'create page content', 'edit own page content',
  38. );
  39. $this->normalUser = $this->drupalCreateUser($permissions);
  40. // Create an admin user.
  41. $permissions[] = 'administer site configuration';
  42. $permissions[] = 'administer permissions';
  43. $permissions[] = 'administer content types';
  44. $this->adminUser = $this->drupalCreateUser($permissions);
  45. }
  46. }
  47. /**
  48. * Test Case for External Links administration functionality.
  49. */
  50. class ExtlinkAdminTestCase extends ExtlinkBaseWebTestCase {
  51. /**
  52. * Get test info.
  53. */
  54. public static function getInfo() {
  55. return array(
  56. 'name' => t('External Links administration functionality'),
  57. 'description' => t('Testing of the External Links administration interface and functionality.'),
  58. 'group' => t('External Links'),
  59. );
  60. }
  61. /**
  62. * Test access to the admin pages.
  63. */
  64. public function testAdminAccess() {
  65. $this->drupalLogin($this->normalUser);
  66. $this->drupalGet(self::EXTLINK_ADMIN_PATH);
  67. $this->assertText(t('Access denied'), 'Normal users should not be able to access the External Links admin pages', 'External Links');
  68. $this->drupalLogin($this->adminUser);
  69. $this->drupalGet(self::EXTLINK_ADMIN_PATH);
  70. $this->assertNoText(t('Access denied'), 'Admin users should be able to access the External Links admin pages', 'External Links');
  71. }
  72. }