3 namespace Drupal\Tests\taxonomy\Kernel\Migrate\d7;
5 use Drupal\taxonomy\Entity\Vocabulary;
6 use Drupal\Tests\migrate_drupal\Kernel\d7\MigrateDrupal7TestBase;
7 use Drupal\taxonomy\VocabularyInterface;
10 * Migrate taxonomy vocabularies to taxonomy.vocabulary.*.yml.
14 class MigrateTaxonomyVocabularyTest extends MigrateDrupal7TestBase {
19 public static $modules = ['taxonomy'];
24 protected function setUp() {
26 $this->executeMigration('d7_taxonomy_vocabulary');
30 * Validate a migrated vocabulary contains the expected values.
33 * Entity ID to load and check.
34 * @param $expected_label
35 * The label the migrated entity should have.
36 * @param $expected_description
37 * The description the migrated entity should have.
38 * @param $expected_hierarchy
39 * The hierarchy setting the migrated entity should have.
40 * @param $expected_weight
41 * The weight the migrated entity should have.
43 protected function assertEntity($id, $expected_label, $expected_description, $expected_hierarchy, $expected_weight) {
44 /** @var \Drupal\taxonomy\VocabularyInterface $entity */
45 $entity = Vocabulary::load($id);
46 $this->assertTrue($entity instanceof VocabularyInterface);
47 $this->assertIdentical($expected_label, $entity->label());
48 $this->assertIdentical($expected_description, $entity->getDescription());
49 $this->assertIdentical($expected_hierarchy, $entity->getHierarchy());
50 $this->assertIdentical($expected_weight, $entity->get('weight'));
54 * Tests the Drupal 7 taxonomy vocabularies to Drupal 8 migration.
56 public function testTaxonomyVocabulary() {
57 $this->assertEntity('tags', 'Tags', 'Use tags to group articles on similar topics into categories.', VocabularyInterface::HIERARCHY_DISABLED, 0);
58 $this->assertEntity('forums', 'Sujet de discussion', 'Forum navigation vocabulary', VocabularyInterface::HIERARCHY_SINGLE, -10);
59 $this->assertEntity('test_vocabulary', 'Test Vocabulary', 'This is the vocabulary description', VocabularyInterface::HIERARCHY_SINGLE, 0);
60 $this->assertEntity('vocabulary_name_much_longer_than', 'vocabulary name clearly different than machine name and much longer than thirty two characters', 'description of vocabulary name much longer than thirty two characters', VocabularyInterface::HIERARCHY_SINGLE, 0);