You are here

function AdminMenuDynamicLinksTestCase::testNodeAdd in Administration menu 6.3

Same name and namespace in other branches
  1. 7.3 tests/admin_menu.test \AdminMenuDynamicLinksTestCase::testNodeAdd()

Tests Add content links.

File

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

Class

AdminMenuDynamicLinksTestCase
Tests appearance, localization, and escaping of dynamic links.

Code

function testNodeAdd() {
  $type = $this
    ->drupalCreateContentType(array(
    'type' => 'article',
    'name' => 'Article',
  ));

  // Verify that "Add content" does not appear for unprivileged users.
  $permissions = $this->basePermissions + array(
    'access content',
  );
  $this->web_user = $this
    ->drupalCreateUser($permissions);
  $this
    ->drupalLogin($this->web_user);
  $this
    ->assertNoText(t('Create content'));

  // Verify "Add content" appears below "Content" for administrative users.
  $permissions = $this->basePermissions + array(
    'administer nodes',
    'access content',
    'create article content',
  );
  $this->admin_user = $this
    ->drupalCreateUser($permissions);
  $this
    ->drupalLogin($this->admin_user);
  $this
    ->assertLinkTrailByTitle(array(
    t('Content management'),
    t('Create content'),
  ));

  // Verify "Add content" appears on the top-level for regular users.
  $permissions = $this->basePermissions + array(
    'access content',
    'create article content',
  );
  $this->web_user = $this
    ->drupalCreateUser($permissions);
  $this
    ->drupalLogin($this->web_user);
  $this
    ->assertLinkTrailByTitle(array(
    // @todo Top-level category links are based on access administration pages
    //   permission only.
    t('Content management'),
    t('Create content'),
  ));
}