function AdminMenuPermissionsTestCase::testPermissions in Administration menu 6
Same name and namespace in other branches
- 6.3 tests/admin_menu.test \AdminMenuPermissionsTestCase::testPermissions()
- 7.3 tests/admin_menu.test \AdminMenuPermissionsTestCase::testPermissions()
Test that the links are added to the page (no JS testing).
File
- tests/
admin_menu.test, line 32 - Administration menu functionality tests.
Class
- AdminMenuPermissionsTestCase
- Test menu links depending on user permissions.
Code
function testPermissions() {
// Anonymous users should not see the menu.
$this
->assertNoRaw('<div id="admin-menu"', t('Admin menu not displayed to anonymous.'));
// Create a new user who can access administration menu, but without the
// permission 'display drupal links'.
$admin_user = $this
->drupalCreateUser(array(
'administer site configuration',
'access administration pages',
'administer nodes',
'access administration menu',
));
$this
->drupalLogin($admin_user);
// Check that the user can see the admin links, but not the drupal links.
$this
->assertRaw('<div id="admin-menu"', t('Administration menu is displayed.'));
$this
->drupalGet('node');
$this
->assertPattern('@<div id="admin-menu".*admin/content/node@s', t('Administer content link found.'));
$this
->assertNoPattern('@<div id="admin-menu".*http://drupal.org@s', t('Drupal links not found.'));
$this
->assertNoPattern('@<div id="admin-menu".*admin/build/contact@s', t('Contact module link not found.'));
// Create a new user with the permission 'display drupal links'.
$admin_user2 = $this
->drupalCreateUser(array(
'administer site configuration',
'access administration pages',
'administer nodes',
'access administration menu',
'display drupal links',
));
$this
->drupalLogin($admin_user2);
$this
->drupalGet('node');
$this
->assertPattern('@<div id="admin-menu".*http://drupal.org@s', t('Drupal links found.'));
$this
->assertNoPattern('@<div id="admin-menu".*admin/build/contact@s', t('Contact module link not found.'));
}