You are here

public function AdminMenuPermissionsTestCase::testCategories in Administration menu 7.3

Tests handling of links pointing to category/overview pages.

File

tests/admin_menu.test, line 186
Tests for the Administration menu module.

Class

AdminMenuPermissionsTestCase
Tests menu links depending on user permissions.

Code

public function testCategories() {

  // Create a user with minimum permissions.
  $admin_user = $this
    ->drupalCreateUser($this->basePermissions);
  $this
    ->drupalLogin($admin_user);

  // Verify that no category links appear.
  $this
    ->assertNoLinkTrailByTitle(array(
    t('Structure'),
  ));
  $this
    ->assertNoLinkTrailByTitle(array(
    t('Configuration'),
  ));

  // Create a user with access to one configuration category.
  $permissions = $this->basePermissions + array(
    'administer users',
  );
  $admin_user = $this
    ->drupalCreateUser($permissions);
  $this
    ->drupalLogin($admin_user);

  // Verify that only expected category links appear.
  $this
    ->assertNoLinkTrailByTitle(array(
    t('Structure'),
  ));
  $this
    ->assertLinkTrailByTitle(array(
    t('People'),
  ));
  $this
    ->assertLinkTrailByTitle(array(
    t('Configuration'),
  ));
  $this
    ->assertLinkTrailByTitle(array(
    t('Configuration'),
    t('People'),
  ));

  // Random picks are sufficient.
  $this
    ->assertNoLinkTrailByTitle(array(
    t('Configuration'),
    t('Media'),
  ));
  $this
    ->assertNoLinkTrailByTitle(array(
    t('Configuration'),
    t('System'),
  ));
}