public function NodeLanguageTest::testNativeLanguageField in Drupal 9
Same name and namespace in other branches
- 8 core/modules/node/tests/src/Functional/Views/NodeLanguageTest.php \Drupal\Tests\node\Functional\Views\NodeLanguageTest::testNativeLanguageField()
Tests native name display in language field.
File
- core/
modules/ node/ tests/ src/ Functional/ Views/ NodeLanguageTest.php, line 254
Class
- NodeLanguageTest
- Tests node language fields, filters, and sorting.
Namespace
Drupal\Tests\node\Functional\ViewsCode
public function testNativeLanguageField() {
$this
->assertLanguageNames();
// Modify test view to display native language names and set translations.
$config = $this
->config('views.view.test_language');
$config
->set('display.default.display_options.fields.langcode.settings.native_language', TRUE);
$config
->save();
\Drupal::languageManager()
->getLanguageConfigOverride('fr', 'language.entity.fr')
->set('label', 'Français')
->save();
\Drupal::languageManager()
->getLanguageConfigOverride('es', 'language.entity.es')
->set('label', 'Español')
->save();
$this
->assertLanguageNames(TRUE);
// Modify test view to use the views built-in language field and test that.
\Drupal::state()
->set('node_test_views.use_basic_handler', TRUE);
Views::viewsData()
->clear();
$config = $this
->config('views.view.test_language');
$config
->set('display.default.display_options.fields.langcode.native_language', FALSE);
$config
->clear('display.default.display_options.fields.langcode.settings');
$config
->clear('display.default.display_options.fields.langcode.type');
$config
->set('display.default.display_options.fields.langcode.plugin_id', 'language');
$config
->save();
$this
->assertLanguageNames();
$config
->set('display.default.display_options.fields.langcode.native_language', TRUE)
->save();
$this
->assertLanguageNames(TRUE);
}