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