function MigrateTaxonomyTermTest::testTaxonomyTermEntityTranslations
Tests the migration of taxonomy term entity translations.
File
-
core/
modules/ taxonomy/ tests/ src/ Kernel/ Migrate/ d7/ MigrateTaxonomyTermTest.php, line 198
Class
- MigrateTaxonomyTermTest
- Upgrade taxonomy terms.
Namespace
Drupal\Tests\taxonomy\Kernel\Migrate\d7Code
public function testTaxonomyTermEntityTranslations() {
$manager = $this->container
->get('content_translation.manager');
// Get the term and its translations.
$term = Term::load(4);
$term_fr = $term->getTranslation('fr');
$term_is = $term->getTranslation('is');
// Test that fields translated with Entity Translation are migrated.
$this->assertSame('Term3 in plain old English', $term->getName());
$this->assertSame('Term3 en français s\'il vous plaît', $term_fr->getName());
$this->assertSame('Term3 á íslensku', $term_is->getName());
$this->assertSame('The third term in plain old English.', $term->getDescription());
$this->assertSame('The third term en français s\'il vous plaît.', $term_fr->getDescription());
$this->assertSame('The third term á íslensku.', $term_is->getDescription());
$this->assertSame('full_html', $term->getFormat());
$this->assertSame('filtered_html', $term_fr->getFormat());
$this->assertSame('plain_text', $term_is->getFormat());
$this->assertSame('6', $term->field_integer->value);
$this->assertSame('5', $term_fr->field_integer->value);
$this->assertSame('4', $term_is->field_integer->value);
// Test that the French translation metadata is correctly migrated.
$metadata_fr = $manager->getTranslationMetadata($term_fr);
$this->assertTrue($metadata_fr->isPublished());
$this->assertSame('en', $metadata_fr->getSource());
$this->assertSame('2', $metadata_fr->getAuthor()->uid->value);
$this->assertSame('1531922267', $metadata_fr->getCreatedTime());
$this->assertSame('1531922268', $metadata_fr->getChangedTime());
$this->assertTrue($metadata_fr->isOutdated());
// Test that the Icelandic translation metadata is correctly migrated.
$metadata_is = $manager->getTranslationMetadata($term_is);
$this->assertFalse($metadata_is->isPublished());
$this->assertSame('en', $metadata_is->getSource());
$this->assertSame('1', $metadata_is->getAuthor()->uid->value);
$this->assertSame('1531922278', $metadata_is->getCreatedTime());
$this->assertSame('1531922279', $metadata_is->getChangedTime());
$this->assertFalse($metadata_is->isOutdated());
// Test that untranslatable properties are the same as the source language.
$this->assertSame($term->bundle(), $term_fr->bundle());
$this->assertSame($term->bundle(), $term_is->bundle());
$this->assertSame($term->getWeight(), $term_fr->getWeight());
$this->assertSame($term->getWeight(), $term_is->getWeight());
$this->assertSame($term->parent->terget_id, $term_fr->parent->terget_id);
$this->assertSame($term->parent->terget_id, $term_is->parent->terget_id);
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.