You are here

public function LanguageContextTest::testLanguageNegotiation in GraphQL 8.3

Test the language negotiation within a context.

File

tests/src/Kernel/Framework/LanguageContextTest.php, line 134

Class

LanguageContextTest
Test contextual language negotiation.

Namespace

Drupal\Tests\graphql\Kernel\Framework

Code

public function testLanguageNegotiation() {
  $context = $this->container
    ->get('graphql.language_context');
  $this
    ->assertEquals('fr', $context
    ->executeInLanguageContext(function () {
    return \Drupal::service('language_manager')
      ->getCurrentLanguage()
      ->getId();
  }, 'fr'), 'Unexpected language negotiation result.');
}