You are here

public function LanguageCookieNegotiationConfigTest::testLanguageCookieNegotiationConfigFormAccess in Language Cookie 8

Test access to the language_cookie negotiation form.

File

tests/src/Functional/LanguageCookieNegotiationConfigTest.php, line 31

Class

LanguageCookieNegotiationConfigTest
Test the language cookie negotiation config.

Namespace

Drupal\Tests\language_cookie\Functional

Code

public function testLanguageCookieNegotiationConfigFormAccess() {

  // Test access for admin user.
  $this
    ->drupalGet('admin/config/regional/language/detection/language_cookie');
  $this
    ->assertSession()
    ->statusCodeEquals(200);

  // Test access for user with 'administer languages' permission.
  $user = $this
    ->drupalCreateUser([
    'administer languages',
  ]);
  $this
    ->drupalLogin($user);
  $this
    ->drupalGet('admin/config/regional/language/detection/language_cookie');
  $this
    ->assertSession()
    ->statusCodeEquals(200);

  // Test access for user without 'administer languages' permission.
  $user = $this
    ->drupalCreateUser();
  $this
    ->drupalLogin($user);
  $this
    ->drupalGet('admin/config/regional/language/detection/language_cookie');
  $this
    ->assertSession()
    ->statusCodeEquals(403);

  // Test access for anonymous user.
  $this
    ->drupalLogout();
  $this
    ->drupalGet('admin/config/regional/language/detection/language_cookie');
  $this
    ->assertSession()
    ->statusCodeEquals(403);
}