function EntityDefaultLanguageTest::testEntityTranslationDefaultLanguageViaCode
Same name in other branches
- 9 core/modules/language/tests/src/Kernel/EntityDefaultLanguageTest.php \Drupal\Tests\language\Kernel\EntityDefaultLanguageTest::testEntityTranslationDefaultLanguageViaCode()
- 10 core/modules/language/tests/src/Kernel/EntityDefaultLanguageTest.php \Drupal\Tests\language\Kernel\EntityDefaultLanguageTest::testEntityTranslationDefaultLanguageViaCode()
- 11.x core/modules/language/tests/src/Kernel/EntityDefaultLanguageTest.php \Drupal\Tests\language\Kernel\EntityDefaultLanguageTest::testEntityTranslationDefaultLanguageViaCode()
Tests that default language code is properly set for new nodes.
File
-
core/
modules/ language/ tests/ src/ Kernel/ EntityDefaultLanguageTest.php, line 53
Class
- EntityDefaultLanguageTest
- Tests default language code is properly generated for entities.
Namespace
Drupal\Tests\language\KernelCode
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([
'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');
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.