LanguageNegotiation for kernel tests

Created on 20 December 2018, over 6 years ago
Updated 13 March 2023, about 2 years ago

In kernel tests we lack page requests ($this->drupalGet()). We could make use of a custom language negotiator that

  1. helps to render things in a given language
  2. helps to test language url prefixes.
Feature request
Status

Needs work

Version

10.1

Component
Language system 

Last updated 7 days ago

  • Maintained by
  • 🇩🇪Germany @sun
Created by

🇭🇺Hungary czigor

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • 🇺🇸United States dww

    Cool. I'm always interested in making Kernel tests easier, especially for multilingual stuff. 😉

    A few docs nits, but one real point:

    1. +++ b/core/modules/language/tests/language_test/src/Plugin/LanguageNegotiation/LanguageNegotiationTestSessionAndUrl.php
      @@ -0,0 +1,71 @@
      + * Identify language from $_SESSION['language'] and set a language url prefix.
      ...
      + * Use case: in kernel tests we cannot rely on the url prefix to change
      ...
      + * be able to test links with language url prefixes.
      

      s/url/URL/

    2. +++ b/core/modules/language/tests/language_test/src/Plugin/LanguageNegotiation/LanguageNegotiationTestSessionAndUrl.php
      @@ -0,0 +1,71 @@
      + * getLangcode() is taken from LanguageNegotiationUrl and simplified.
      

      Can we add a @see pointing to exactly what class we're talking about here?

    3. +++ b/core/modules/language/tests/language_test/src/Plugin/LanguageNegotiation/LanguageNegotiationTestSessionAndUrl.php
      @@ -0,0 +1,71 @@
      + * processOutbound() is taken from LanguageNegotiationSession and simplified.
      

      Ditto here.

    4. +++ b/core/modules/language/tests/language_test/src/Plugin/LanguageNegotiation/LanguageNegotiationTestSessionAndUrl.php
      @@ -0,0 +1,71 @@
      + *   description = @Translation("Language from a session parameter. Outbound paths get prefix."),
      

      These aren't complete sentences. 😉 How about:

      "Gets the language from a session parameter. Outbound paths get a language prefix."

      or something?

    5. +++ b/core/modules/language/tests/language_test/src/Plugin/LanguageNegotiation/LanguageNegotiationTestSessionAndUrl.php
      @@ -0,0 +1,71 @@
      +class LanguageNegotiationTestSessionAndUrl extends LanguageNegotiationMethodBase implements OutboundPathProcessorInterface {
      

      I don't think we'd commit this change to core without anything using it. Can we modify/add some Kernel tests somewhere to show off why this change makes life better?

    6. +++ b/core/modules/language/tests/language_test/src/Plugin/LanguageNegotiation/LanguageNegotiationTestSessionAndUrl.php
      @@ -0,0 +1,71 @@
      +   * The language negotiation method id.
      

      s/id/ID/

    NW mostly for point 5, but we might as well fix the others while we're at it...

    Thanks!
    -Derek

  • Status changed to Postponed: needs info about 2 years ago
  • 🇺🇸United States smustgrave

    Admittedly I rerolled this when I was getting started. But regards to point 5 I don't have an actual answer so moving to PNMI as this may actually not be needed? Happily to be wrong.

  • 🇺🇸United States smustgrave

    If no one can see the use for this in core, maybe free to close out.

Production build 0.71.5 2024