You are here

public function ExampleMailTest::testUserAccess in Mime Mail 8

Tests module permissions / access to configuration page.

File

modules/mimemail_example/tests/src/Functional/ExampleMailTest.php, line 58

Class

ExampleMailTest
Tests operation of the Mime Mail Example module.

Namespace

Drupal\Tests\mimemail_example\Functional

Code

public function testUserAccess() {

  /** @var \Drupal\Tests\WebAssert $assert */
  $assert = $this
    ->assertSession();

  // Test as anonymous user.
  $this
    ->drupalGet('admin/config/system/mimemail/mimemail_example');
  $assert
    ->statusCodeEquals(403);
  $assert
    ->pageTextContains('Access denied');
  $assert
    ->pageTextContains('You are not authorized to access this page.');

  // Test as authenticated but unprivileged user.
  $this
    ->drupalLogin($this->unprivUser);
  $this
    ->drupalGet('admin/config/system/mimemail/mimemail_example');
  $assert
    ->statusCodeEquals(403);
  $this
    ->drupalLogout();

  // Test as admin user.
  $this
    ->drupalLogin($this->adminUser);
  $this
    ->drupalGet('admin/config/system/mimemail/mimemail_example');
  $assert
    ->statusCodeEquals(200);
  $assert
    ->pageTextContains('Use this form to send a HTML message to an email address. No spamming!');
  $this
    ->drupalLogout();
}