1.20.x admin_bar.test AdminBarDynamicLinksTestCase::testNodeAdd()

Tests Add content links.

File

modules/admin_bar/tests/admin_bar.test, line 329
Tests for the Administration bar module.

Class

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

Code

function testNodeAdd() {
  $type = $this->backdropCreateContentType(array('type' => 'post', 'name' => 'Post'));

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

  // Verify "Add content" appears below "Content" for administrative users.
  $permissions = $this->basePermissions + array(
    'access content overview',
    'create post content',
  );
  $this->admin_user = $this->backdropCreateUser($permissions);
  $this->backdropLogin($this->admin_user);
  $this->assertLinkTrailByTitle(array(
    t('Content'),
    t('Add content'),
  ));

  // Verify "Add content" appears on the top-level for regular users.
  $permissions = $this->basePermissions + array(
    'create post content',
  );
  $this->web_user = $this->backdropCreateUser($permissions);
  $this->backdropLogin($this->web_user);
  $this->assertLinkTrailByTitle(array(
    t('Add content'),
  ));
}