MigrateTaxonomyVocabularyTest.php

Same filename in this branch
  1. 9 core/modules/taxonomy/tests/src/Kernel/Migrate/d7/MigrateTaxonomyVocabularyTest.php
Same filename in other branches
  1. 8.9.x core/modules/taxonomy/tests/src/Kernel/Migrate/d6/MigrateTaxonomyVocabularyTest.php
  2. 8.9.x core/modules/taxonomy/tests/src/Kernel/Migrate/d7/MigrateTaxonomyVocabularyTest.php
  3. 10 core/modules/forum/tests/src/Kernel/Migrate/d6/MigrateTaxonomyVocabularyTest.php
  4. 10 core/modules/forum/tests/src/Kernel/Migrate/d7/MigrateTaxonomyVocabularyTest.php
  5. 10 core/modules/taxonomy/tests/src/Kernel/Migrate/d6/MigrateTaxonomyVocabularyTest.php
  6. 10 core/modules/taxonomy/tests/src/Kernel/Migrate/d7/MigrateTaxonomyVocabularyTest.php
  7. 11.x core/modules/forum/tests/src/Kernel/Migrate/d6/MigrateTaxonomyVocabularyTest.php
  8. 11.x core/modules/forum/tests/src/Kernel/Migrate/d7/MigrateTaxonomyVocabularyTest.php
  9. 11.x core/modules/taxonomy/tests/src/Kernel/Migrate/d6/MigrateTaxonomyVocabularyTest.php
  10. 11.x core/modules/taxonomy/tests/src/Kernel/Migrate/d7/MigrateTaxonomyVocabularyTest.php

Namespace

Drupal\Tests\taxonomy\Kernel\Migrate\d6

File

core/modules/taxonomy/tests/src/Kernel/Migrate/d6/MigrateTaxonomyVocabularyTest.php

View source
<?php

namespace Drupal\Tests\taxonomy\Kernel\Migrate\d6;

use Drupal\taxonomy\Entity\Vocabulary;
use Drupal\Tests\migrate_drupal\Kernel\d6\MigrateDrupal6TestBase;

/**
 * Migrate taxonomy vocabularies to taxonomy.vocabulary.*.yml.
 *
 * @group migrate_drupal_6
 */
class MigrateTaxonomyVocabularyTest extends MigrateDrupal6TestBase {
    
    /**
     * {@inheritdoc}
     */
    protected static $modules = [
        'taxonomy',
    ];
    
    /**
     * {@inheritdoc}
     */
    protected function setUp() : void {
        parent::setUp();
        $this->executeMigration('d6_taxonomy_vocabulary');
    }
    
    /**
     * Tests the Drupal 6 taxonomy vocabularies to Drupal 8 migration.
     */
    public function testTaxonomyVocabulary() {
        for ($i = 0; $i < 3; $i++) {
            $j = $i + 1;
            $vocabulary = Vocabulary::load("vocabulary_{$j}_i_{$i}_");
            $this->assertSame($this->getMigration('d6_taxonomy_vocabulary')
                ->getIdMap()
                ->lookupDestinationIds([
                $j,
            ]), [
                [
                    $vocabulary->id(),
                ],
            ]);
            $this->assertSame("vocabulary {$j} (i={$i})", $vocabulary->label());
            $this->assertSame("description of vocabulary {$j} (i={$i})", $vocabulary->getDescription());
            $this->assertSame(4 + $i, $vocabulary->get('weight'));
        }
        $vocabulary = Vocabulary::load('vocabulary_name_much_longer_th');
        $this->assertSame('vocabulary name much longer than thirty two characters', $vocabulary->label());
        $this->assertSame('description of vocabulary name much longer than thirty two characters', $vocabulary->getDescription());
        $this->assertSame(7, $vocabulary->get('weight'));
    }

}

Classes

Title Deprecated Summary
MigrateTaxonomyVocabularyTest Migrate taxonomy vocabularies to taxonomy.vocabulary.*.yml.

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.