You are here

public function TaxonomyPermissionsTestBase::setUp in Taxonomy Permissions 8

Setup.

Overrides BrowserTestBase::setUp

File

src/Tests/TaxonomyPermissionsTestBase.php, line 105

Class

TaxonomyPermissionsTestBase
General setup and helper function for testing taxonomy permissions module.

Namespace

Drupal\taxonomy_permissions\Tests

Code

public function setUp() {
  parent::setUp();

  // Create vocabulary and terms.
  $this->vocabulary = $this
    ->createVocabulary();
  $this->term1 = $this
    ->createTerm($this->vocabulary);

  // We remove standard permission provided by default.
  $perms[] = 'view terms in ' . $this->vocabulary
    ->id();
  user_role_revoke_permissions(AccountInterface::ANONYMOUS_ROLE, $perms);
  user_role_revoke_permissions(AccountInterface::AUTHENTICATED_ROLE, $perms);
  $this
    ->drupalCreateContentType([
    'type' => 'article',
  ]);
  $this->authorizedUser = $this
    ->drupalCreateUser([
    'create article content',
    'edit any article content',
    'access content',
    'view terms in ' . $this->vocabulary
      ->id(),
  ]);
  $this->basicUser = $this
    ->drupalCreateUser([
    'create article content',
    'edit any article content',
    'access content',
  ]);
  $field_name = 'field_term';
  $this
    ->attachFields($field_name);
  $this->article1 = $this
    ->createSimpleArticle('Article 1', $field_name, $this->term1
    ->id());
}