function VocabularyPermissionsTest::testVocabularyPermissionsVocabulary

Same name and namespace in other branches
  1. 9 core/modules/taxonomy/tests/src/Functional/VocabularyPermissionsTest.php \Drupal\Tests\taxonomy\Functional\VocabularyPermissionsTest::testVocabularyPermissionsVocabulary()
  2. 8.9.x core/modules/taxonomy/tests/src/Functional/VocabularyPermissionsTest.php \Drupal\Tests\taxonomy\Functional\VocabularyPermissionsTest::testVocabularyPermissionsVocabulary()
  3. 11.x core/modules/taxonomy/tests/src/Functional/VocabularyPermissionsTest.php \Drupal\Tests\taxonomy\Functional\VocabularyPermissionsTest::testVocabularyPermissionsVocabulary()

Create, edit and delete a vocabulary via the user interface.

File

core/modules/taxonomy/tests/src/Functional/VocabularyPermissionsTest.php, line 40

Class

VocabularyPermissionsTest
Tests the taxonomy vocabulary permissions.

Namespace

Drupal\Tests\taxonomy\Functional

Code

public function testVocabularyPermissionsVocabulary() : void {
  // VocabularyTest.php already tests for user with "administer taxonomy"
  // permission.
  // Test as user without proper permissions.
  $authenticated_user = $this->drupalCreateUser([]);
  $this->drupalLogin($authenticated_user);
  $assert_session = $this->assertSession();
  // Visit the main taxonomy administration page.
  $this->drupalGet('admin/structure/taxonomy');
  $assert_session->statusCodeEquals(403);
  // Test as user with "access taxonomy overview" permissions.
  $proper_user = $this->drupalCreateUser([
    'access taxonomy overview',
  ]);
  $this->drupalLogin($proper_user);
  // Visit the main taxonomy administration page.
  $this->drupalGet('admin/structure/taxonomy');
  $assert_session->statusCodeEquals(200);
  $assert_session->pageTextContains('Vocabulary name');
  $assert_session->linkNotExists('Add vocabulary');
}

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