Issue #2161177 by plopesc, yched: 'language' extra field doesn't display the language selected in the node form.

8.0.x
Alex Pott 2014-02-13 10:45:48 +00:00
parent 31584f0229
commit 7e41e96ce9
2 changed files with 53 additions and 1 deletions

View File

@ -50,7 +50,7 @@ class NodeViewBuilder extends EntityViewBuilder {
$entity->content['langcode'] = array(
'#type' => 'item',
'#title' => t('Language'),
'#markup' => $this->languageManager->getLanguageName($langcode),
'#markup' => $entity->language()->name,
'#prefix' => '<div id="field-language-display">',
'#suffix' => '</div>'
);

View File

@ -0,0 +1,52 @@
<?php
/**
* @file
* Contains \Drupal\node\Tests\NodeViewLanguageTest.
*/
namespace Drupal\node\Tests;
use Drupal\Core\Language\Language;
/**
* Tests the node language extra field display.
*/
class NodeViewLanguageTest extends NodeTestBase {
/**
* Modules to enable.
*
* @var array
*/
public static $modules = array('node', 'datetime', 'language');
public static function getInfo() {
return array(
'name' => 'Node view language field',
'description' => 'Tests the language extra field display.',
'group' => 'Node',
);
}
/**
* Tests the language extra field display.
*/
public function testViewLanguage() {
// Add Spanish language.
$language = new Language(array('id' => 'es'));
language_save($language);
// Set language field visible.
entity_get_display('node', 'page', 'full')
->setComponent('langcode')
->save();
// Create a node in Spanish.
$node = $this->drupalCreateNode(array('langcode' => 'es'));
$this->drupalGet($node->getSystemPath());
$this->assertText('Spanish','The language field is displayed properly.');
}
}