You are here

function AdminMenuDynamicLinksTest::testNodeAdd in Administration menu 8.3

Tests Add content links.

File

lib/Drupal/admin_menu/Tests/AdminMenuDynamicLinksTest.php, line 81

Class

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

Namespace

Drupal\admin_menu\Tests

Code

function testNodeAdd() {

  // The $type is used on tests. @codingStandardsIgnoreLine
  $type = $this
    ->drupalCreateContentType([
    'type' => 'article',
    'name' => 'Article',
  ]);

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

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

  // Verify "Add content" appears on the top-level for regular users.
  $permissions = $this->basePermissions + [
    'access content',
    'create article content',
  ];
  $this->web_user = $this
    ->drupalCreateUser($permissions);
  $this
    ->drupalLogin($this->web_user);
  $this
    ->assertLinkTrailByTitle([
    t('Add content'),
  ]);
}