You are here

public function LanguageCookieConditionTest::testAjax in Language Cookie 8

Test the "xml_http_request" condition.

File

tests/src/Functional/LanguageCookieConditionTest.php, line 98

Class

LanguageCookieConditionTest
Tests that the condition plugins work.

Namespace

Drupal\Tests\language_cookie\Functional

Code

public function testAjax() {
  $node = $this
    ->drupalCreateNode();
  $headers = [];
  $this
    ->getSession()
    ->setCookie('language', NULL);
  $this
    ->drupalGet('fr/node/' . $node
    ->id(), [], $headers);
  $this
    ->assertSession()
    ->cookieEquals('language', 'fr');
  $headers['X-Requested-With'] = 'XMLHttpRequest';
  $this
    ->getSession()
    ->setCookie('language', NULL);
  $this
    ->drupalGet('fr/node/' . $node
    ->id(), [], $headers);
  $this
    ->assertEmpty($this
    ->getSession()
    ->getCookie('language'));
}