You are here

public function TaxonomyPermissionsTestBase::testAccessFormTerm in Taxonomy Permissions 8

Tests if a user without permissions can access to the field form.

File

src/Tests/TaxonomyPermissionsTestBase.php, line 171

Class

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

Namespace

Drupal\taxonomy_permissions\Tests

Code

public function testAccessFormTerm() {
  $this
    ->drupalLogin($this->authorizedUser);
  $this
    ->drupalGet("node/{$this->article1->id()}/edit");
  $this
    ->assertResponse(200);
  $this
    ->assertFieldByName('field_term[0][target_id]', $this->term1
    ->getName() . ' (' . $this->term1
    ->id() . ')', 'The expected value is found in the input field');
  $this
    ->drupalLogin($this->basicUser);
  $this
    ->drupalGet("node/{$this->article1->id()}/edit");
  $this
    ->assertResponse(200);
  $this
    ->assertNoFieldByName('field_term[0][target_id]', $this->term1
    ->getName() . ' (' . $this->term1
    ->id() . ')', 'The input field taxonomy reference is not accessible');
}