function LanguageUILanguageNegotiationTest::doRunTest

Same name in other branches
  1. 9 core/modules/language/tests/src/Functional/LanguageUILanguageNegotiationTest.php \Drupal\Tests\language\Functional\LanguageUILanguageNegotiationTest::doRunTest()
  2. 8.9.x core/modules/language/tests/src/Functional/LanguageUILanguageNegotiationTest.php \Drupal\Tests\language\Functional\LanguageUILanguageNegotiationTest::doRunTest()
  3. 11.x core/modules/language/tests/src/Functional/LanguageUILanguageNegotiationTest.php \Drupal\Tests\language\Functional\LanguageUILanguageNegotiationTest::doRunTest()
1 call to LanguageUILanguageNegotiationTest::doRunTest()
LanguageUILanguageNegotiationTest::testUILanguageNegotiation in core/modules/language/tests/src/Functional/LanguageUILanguageNegotiationTest.php
Tests for language switching by URL path.

File

core/modules/language/tests/src/Functional/LanguageUILanguageNegotiationTest.php, line 417

Class

LanguageUILanguageNegotiationTest
Tests the language UI for language switching.

Namespace

Drupal\Tests\language\Functional

Code

protected function doRunTest($test) {
    $test += [
        'path_options' => [],
    ];
    if (!empty($test['language_negotiation'])) {
        $method_weights = array_flip($test['language_negotiation']);
        $this->container
            ->get('language_negotiator')
            ->saveConfiguration(LanguageInterface::TYPE_INTERFACE, $method_weights);
    }
    if (!empty($test['language_negotiation_url_part'])) {
        $this->config('language.negotiation')
            ->set('url.source', $test['language_negotiation_url_part'])
            ->save();
    }
    if (!empty($test['language_test_domain'])) {
        \Drupal::state()->set('language_test.domain', $test['language_test_domain']);
    }
    $this->container
        ->get('language_manager')
        ->reset();
    $this->drupalGet($test['path'], $test['path_options'], $test['http_header']);
    $this->assertSession()
        ->pageTextContains($test['expect']);
    $this->assertSession()
        ->statusMessageContains('Language negotiation method: ' . $test['expected_method_id'], 'status');
    // Get the private file and ensure it is a 200. It is important to
    // invalidate the router cache to ensure the routing system runs a full
    // match.
    Cache::invalidateTags([
        'route_match',
    ]);
    $this->drupalGet('system/files/test/private-file-test.txt');
    $this->assertSession()
        ->statusCodeEquals(200);
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.