public function EntityDefaultLanguageTest::testEntityTranslationDefaultLanguageViaCode in Zircon Profile 8
Same name and namespace in other branches
- 8.0 core/modules/language/src/Tests/EntityDefaultLanguageTest.php \Drupal\language\Tests\EntityDefaultLanguageTest::testEntityTranslationDefaultLanguageViaCode()
Tests that default language code is properly set for new nodes.
File
- core/
modules/ language/ src/ Tests/ EntityDefaultLanguageTest.php, line 51 - Contains \Drupal\language\Tests\EntityDefaultLanguageTest.
Class
- EntityDefaultLanguageTest
- Tests default language code is properly generated for entities.
Namespace
Drupal\language\TestsCode
public function testEntityTranslationDefaultLanguageViaCode() {
// With language module activated, and a content type that is configured to
// have no language by default, a new node of this content type will have
// "und" language code when language is not specified.
$node = $this
->createNode('ctund');
$this
->assertEqual($node->langcode->value, LanguageInterface::LANGCODE_NOT_SPECIFIED);
// With language module activated, and a content type that is configured to
// have no language by default, a new node of this content type will have
// "es" language code when language is specified as "es".
$node = $this
->createNode('ctund', 'es');
$this
->assertEqual($node->langcode->value, 'es');
// With language module activated, and a content type that is configured to
// have language "es" by default, a new node of this content type will have
// "es" language code when language is not specified.
$node = $this
->createNode('ctes');
$this
->assertEqual($node->langcode->value, 'es');
// With language module activated, and a content type that is configured to
// have language "es" by default, a new node of this content type will have
// "en" language code when language "en" is specified.
$node = $this
->createNode('ctes', 'en');
$this
->assertEqual($node->langcode->value, 'en');
// Disable language module.
$this
->disableModules(array(
'language',
));
// With language module disabled, and a content type that is configured to
// have no language specified by default, a new node of this content type
// will have site's default language code when language is not specified.
$node = $this
->createNode('ctund');
$this
->assertEqual($node->langcode->value, 'en');
// With language module disabled, and a content type that is configured to
// have no language specified by default, a new node of this type will have
// "es" language code when language "es" is specified.
$node = $this
->createNode('ctund', 'es');
$this
->assertEqual($node->langcode->value, 'es');
// With language module disabled, and a content type that is configured to
// have language "es" by default, a new node of this type will have site's
// default language code when language is not specified.
$node = $this
->createNode('ctes');
$this
->assertEqual($node->langcode->value, 'en');
// With language module disabled, and a content type that is configured to
// have language "es" by default, a new node of this type will have "en"
// language code when language "en" is specified.
$node = $this
->createNode('ctes', 'en');
$this
->assertEqual($node->langcode->value, 'en');
}