You are here

public function LanguageAccessBrowserTest::testBrowserLanguageNegotiation in Language access 8

Test language access browser negotiation.

@dataProvider browserLanguageNegotiationDataProvider

File

tests/src/Kernel/LanguageAccessBrowserTest.php, line 63

Class

LanguageAccessBrowserTest
Test language access browser test.

Namespace

Drupal\Tests\language_access\Kernel

Code

public function testBrowserLanguageNegotiation(string $expected, array $user_permissions, $http_accept_language) {

  /** @var \Drupal\language_access\Plugin\LanguageNegotiation\LanguageAccessNegotiationBrowser $browser_negotiation_method */
  $this->languageNegotiator
    ->setCurrentUser($this
    ->createUser($user_permissions));
  $browser_negotiation_method = $this->languageNegotiator
    ->getNegotiationMethodInstance('language-browser');
  $this
    ->assertInstanceOf(LanguageAccessNegotiationBrowser::class, $browser_negotiation_method);
  $request = new Request([], [], [], [], [], [
    'HTTP_ACCEPT_LANGUAGE' => $http_accept_language,
  ]);
  $this
    ->assertEquals($expected, $browser_negotiation_method
    ->getLangcode($request));
}