public function UpcastingTest::testEntityLanguage in Drupal 9
Same name and namespace in other branches
- 8 core/modules/system/tests/src/Functional/ParamConverter/UpcastingTest.php \Drupal\Tests\system\Functional\ParamConverter\UpcastingTest::testEntityLanguage()
- 10 core/modules/system/tests/src/Functional/ParamConverter/UpcastingTest.php \Drupal\Tests\system\Functional\ParamConverter\UpcastingTest::testEntityLanguage()
Confirms entity is shown in user's language by default.
File
- core/
modules/ system/ tests/ src/ Functional/ ParamConverter/ UpcastingTest.php, line 70
Class
- UpcastingTest
- Tests upcasting of url arguments to entities.
Namespace
Drupal\Tests\system\Functional\ParamConverterCode
public function testEntityLanguage() {
$language = ConfigurableLanguage::createFromLangcode('de');
$language
->save();
\Drupal::configFactory()
->getEditable('language.negotiation')
->set('url.prefixes', [
'de' => 'de',
])
->save();
// The container must be recreated after adding a new language.
$this
->rebuildContainer();
$node = $this
->drupalCreateNode([
'title' => 'English label',
]);
$translation = $node
->addTranslation('de');
$translation
->setTitle('Deutscher Titel')
->save();
$this
->drupalGet("/paramconverter_test/node/" . $node
->id() . "/test_language");
$this
->assertSession()
->pageTextContains("English label");
$this
->drupalGet("paramconverter_test/node/" . $node
->id() . "/test_language", [
'language' => $language,
]);
$this
->assertSession()
->pageTextContains("Deutscher Titel");
}