Security update for Core, with self-updated composer
[yaffs-website] / web / core / modules / taxonomy / tests / src / Kernel / Migrate / d7 / MigrateTaxonomyVocabularyTest.php
1 <?php
2
3 namespace Drupal\Tests\taxonomy\Kernel\Migrate\d7;
4
5 use Drupal\taxonomy\Entity\Vocabulary;
6 use Drupal\Tests\migrate_drupal\Kernel\d7\MigrateDrupal7TestBase;
7 use Drupal\taxonomy\VocabularyInterface;
8
9 /**
10  * Migrate taxonomy vocabularies to taxonomy.vocabulary.*.yml.
11  *
12  * @group taxonomy
13  */
14 class MigrateTaxonomyVocabularyTest extends MigrateDrupal7TestBase {
15
16   /**
17    * {@inheritdoc}
18    */
19   public static $modules = ['taxonomy'];
20
21   /**
22    * {@inheritdoc}
23    */
24   protected function setUp() {
25     parent::setUp();
26     $this->executeMigration('d7_taxonomy_vocabulary');
27   }
28
29   /**
30    * Validate a migrated vocabulary contains the expected values.
31    *
32    * @param $id
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.
42    */
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'));
51   }
52
53   /**
54    * Tests the Drupal 7 taxonomy vocabularies to Drupal 8 migration.
55    */
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);
61   }
62
63 }