function AccessAnnouncementTest::testAnnounceWithoutPermission

Same name in other branches
  1. 10 core/modules/announcements_feed/tests/src/FunctionalJavascript/AccessAnnouncementTest.php \Drupal\Tests\announcements_feed\FunctionalJavascript\AccessAnnouncementTest::testAnnounceWithoutPermission()

Testing announce icon without announce permission.

File

core/modules/announcements_feed/tests/src/FunctionalJavascript/AccessAnnouncementTest.php, line 65

Class

AccessAnnouncementTest
Test the access announcement permissions to get access announcement icon.

Namespace

Drupal\Tests\announcements_feed\FunctionalJavascript

Code

public function testAnnounceWithoutPermission() : void {
    // User without "access announcements" permission.
    $account = $this->drupalCreateUser([
        'access toolbar',
    ]);
    $this->drupalLogin($account);
    $this->drupalGet('<front>');
    // Check that the user can see the toolbar.
    $this->assertSession()
        ->elementExists('css', '#toolbar-bar');
    // But not the announcements.
    $this->assertSession()
        ->elementNotExists('css', '.toolbar-icon-announce');
    $this->drupalGet('admin/announcements_feed');
    $this->assertSession()
        ->responseContains('You are not authorized to access this page.');
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.