MigrateTaxonomyVocabularyTest.php in Drupal 9
File
core/modules/taxonomy/tests/src/Kernel/Migrate/d7/MigrateTaxonomyVocabularyTest.php
View source
<?php
namespace Drupal\Tests\taxonomy\Kernel\Migrate\d7;
use Drupal\taxonomy\Entity\Vocabulary;
use Drupal\Tests\migrate_drupal\Kernel\d7\MigrateDrupal7TestBase;
use Drupal\taxonomy\VocabularyInterface;
class MigrateTaxonomyVocabularyTest extends MigrateDrupal7TestBase {
protected static $modules = [
'taxonomy',
'text',
];
protected function setUp() : void {
parent::setUp();
$this
->executeMigration('d7_taxonomy_vocabulary');
}
protected function assertEntity($id, $expected_label, $expected_description, $expected_weight) {
$entity = Vocabulary::load($id);
$this
->assertInstanceOf(VocabularyInterface::class, $entity);
$this
->assertSame($expected_label, $entity
->label());
$this
->assertSame($expected_description, $entity
->getDescription());
$this
->assertSame($expected_weight, $entity
->get('weight'));
}
public function testTaxonomyVocabulary() {
$this
->assertEntity('tags', 'Tags', 'Use tags to group articles on similar topics into categories.', 0);
$this
->assertEntity('forums', 'Sujet de discussion', 'Forum navigation vocabulary', -10);
$this
->assertEntity('test_vocabulary', 'Test Vocabulary', 'This is the vocabulary description', 0);
$this
->assertEntity('vocabulary_name_much_longer_th', 'vocabulary name clearly different than machine name and much longer than thirty two characters', 'description of vocabulary name much longer than thirty two characters', 0);
}
}