You are here

public function LanguageCookieNegotiationConfigTest::testLanguageCookieHttpOnlyOption in Language Cookie 8

Test the language_cookie http_only config option.

File

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

Class

LanguageCookieNegotiationConfigTest
Test the language cookie negotiation config.

Namespace

Drupal\Tests\language_cookie\Functional

Code

public function testLanguageCookieHttpOnlyOption() {
  $config = $this
    ->config('language_cookie.negotiation');
  $config
    ->set('http_only', TRUE);
  $config
    ->save();
  $node = $this
    ->drupalCreateNode();
  $this
    ->drupalGet('fr/node/' . $node
    ->id());
  $this
    ->assertRegExp('/httponly/i', $this
    ->getSession()
    ->getResponseHeader('Set-Cookie'), 'Cookie contains httpOnly option.');
  $config
    ->set('http_only', FALSE);
  $config
    ->save();
  $this
    ->drupalGet('en/node/' . $node
    ->id());
  $this
    ->assertNotRegExp('/httponly/i', $this
    ->getSession()
    ->getResponseHeader('Set-Cookie'), 'Cookie contains httpOnly option.');
}