protected function LanguageUILanguageNegotiationTest::doRunTest in Drupal 10
Same name and namespace in other branches
- 8 core/modules/language/tests/src/Functional/LanguageUILanguageNegotiationTest.php \Drupal\Tests\language\Functional\LanguageUILanguageNegotiationTest::doRunTest()
- 9 core/modules/language/tests/src/Functional/LanguageUILanguageNegotiationTest.php \Drupal\Tests\language\Functional\LanguageUILanguageNegotiationTest::doRunTest()
File
- core/
modules/ language/ tests/ src/ Functional/ LanguageUILanguageNegotiationTest.php, line 402
Class
- LanguageUILanguageNegotiationTest
- Tests the language UI for language switching.
Namespace
Drupal\Tests\language\FunctionalCode
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);
}