You are here

public function PermissionsTest::testPermissionsExist in Metatag 8

Confirm each permission is listed.

User 1 will be logged in from the setUp() method.

File

metatag_extended_perms/tests/src/Functional/PermissionsTest.php, line 99

Class

PermissionsTest
Verify the new permissions are added.

Namespace

Drupal\Tests\metatag_extended_perms\Functional

Code

public function testPermissionsExist() {

  // Load the front page.
  $this
    ->drupalGet('admin/people/permissions');

  // Confirm that the site didn't throw a server error or something else.
  $session = $this
    ->assertSession();
  $session
    ->statusCodeEquals(200);

  // Confirm that the page contains the standard text indicating this is the
  // permissions page.
  $session
    ->pageTextContains('Administer modules');
  $session
    ->pageTextContains('Administer site configuration');
  $session
    ->pageTextContains('Administer themes');
  $session
    ->pageTextContains('Administer software updates');

  // Look for each of the meta tags.
  foreach ($this->permissions as $group => $perms) {
    foreach ($perms as $tag_name => $tag_label) {

      // Look for the checkbox.
      $session
        ->fieldExists('anonymous[access metatag ' . $group . '__' . $tag_name . ']');
    }
  }
}