You are here

public function PermissionsTest::testPermissions in Term Merge 8

Tests that users without the merge taxonomy terms permission can't merge.

@dataProvider permissionsProvider

Parameters

array $permissions: The permissions the test user should have.

int $expectedStatusCode: The status code that should be in the response.

Throws

\Behat\Mink\Exception\ExpectationException

\Drupal\Core\Entity\EntityStorageException

File

tests/src/Functional/PermissionsTest.php, line 59

Class

PermissionsTest
Tests the Term Merge module permissions.

Namespace

Drupal\Tests\term_merge\Functional

Code

public function testPermissions(array $permissions, $expectedStatusCode) {

  // Data providers run before the setUp. This causes fatal errors when
  // running the test. We therefore have to do a replacement.
  foreach ($permissions as $key => $permission) {
    $permissions[$key] = str_replace('%vocabulary_id', $this->vocabulary
      ->id(), $permission);
  }
  $user = $this
    ->drupalCreateUser($permissions);
  $this
    ->drupalLogin($user);
  $this
    ->drupalGet("/admin/structure/taxonomy/manage/{$this->vocabulary->id()}/merge");
  $this
    ->assertSession()
    ->statusCodeEquals($expectedStatusCode);
}