public function ContentTranslationModuleInstallTest::testFieldUpdates in Drupal 8
Same name and namespace in other branches
- 9 core/modules/content_translation/tests/src/Kernel/ContentTranslationModuleInstallTest.php \Drupal\Tests\content_translation\Kernel\ContentTranslationModuleInstallTest::testFieldUpdates()
- 10 core/modules/content_translation/tests/src/Kernel/ContentTranslationModuleInstallTest.php \Drupal\Tests\content_translation\Kernel\ContentTranslationModuleInstallTest::testFieldUpdates()
Test that content translation fields are created upon module installation.
File
- core/
modules/ content_translation/ tests/ src/ Kernel/ ContentTranslationModuleInstallTest.php, line 63
Class
- ContentTranslationModuleInstallTest
- Tests content translation for modules that provide translatable bundles.
Namespace
Drupal\Tests\content_translation\KernelCode
public function testFieldUpdates() {
// The module ships a translatable bundle of the 'entity_test_with_bundle'
// entity type.
$this
->installConfig([
'content_translation_test',
]);
$entity = EntityTestWithBundle::create([
'type' => 'test',
'langcode' => $this->sourceLangcode,
]);
$entity
->save();
// Add a translation with some translation metadata.
$translation = $entity
->addTranslation($this->translationLangcode);
$translation_metadata = $this->contentTranslationManager
->getTranslationMetadata($translation);
$translation_metadata
->setSource($this->sourceLangcode)
->setOutdated(TRUE);
$translation
->save();
// Make sure the translation metadata has been saved correctly.
$entity = EntityTestWithBundle::load($entity
->id());
$translation = $entity
->getTranslation($this->translationLangcode);
$translation_metadata = $this->contentTranslationManager
->getTranslationMetadata($translation);
$this
->assertSame($this->sourceLangcode, $translation_metadata
->getSource());
$this
->assertSame(TRUE, $translation_metadata
->isOutdated());
}