public function NodeLanguageTest::testNativeLanguageField in Zircon Profile 8.0
Same name and namespace in other branches
- 8 core/modules/node/src/Tests/Views/NodeLanguageTest.php \Drupal\node\Tests\Views\NodeLanguageTest::testNativeLanguageField()
Tests native name display in language field.
File
- core/
modules/ node/ src/ Tests/ Views/ NodeLanguageTest.php, line 253 - Contains \Drupal\node\Tests\Views\NodeLanguageTest.
Class
- NodeLanguageTest
- Tests node language fields, filters, and sorting.
Namespace
Drupal\node\Tests\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);
}