fa5c7f3a16461df7769e5e7413b09f736fdaa661
[yaffs-website] / web / core / modules / taxonomy / tests / src / Kernel / Migrate / d6 / MigrateVocabularyFieldTest.php
1 <?php
2
3 namespace Drupal\Tests\taxonomy\Kernel\Migrate\d6;
4
5 use Drupal\field\Entity\FieldStorageConfig;
6 use Drupal\Tests\migrate_drupal\Kernel\d6\MigrateDrupal6TestBase;
7
8 /**
9  * Vocabulary field migration.
10  *
11  * @group migrate_drupal_6
12  */
13 class MigrateVocabularyFieldTest extends MigrateDrupal6TestBase {
14
15   /**
16    * {@inheritdoc}
17    */
18   public static $modules = ['taxonomy', 'menu_ui'];
19
20   /**
21    * {@inheritdoc}
22    */
23   protected function setUp() {
24     parent::setUp();
25     $this->migrateTaxonomy();
26   }
27
28   /**
29    * Tests the Drupal 6 vocabulary-node type association to Drupal 8 migration.
30    */
31   public function testVocabularyField() {
32     // Test that the field exists.
33     $field_storage_id = 'node.field_tags';
34     /** @var \Drupal\field\FieldStorageConfigInterface $field_storage */
35     $field_storage = FieldStorageConfig::load($field_storage_id);
36     $this->assertSame($field_storage_id, $field_storage->id());
37
38     $settings = $field_storage->getSettings();
39     $this->assertSame('taxonomy_term', $settings['target_type'], "Target type is correct.");
40     $this->assertSame(1, $field_storage->getCardinality(), "Field cardinality in 1.");
41
42     $this->assertSame(['node', 'field_tags'], $this->getMigration('d6_vocabulary_field')->getIdMap()->lookupDestinationId([4]), "Test IdMap");
43
44     // Tests that a vocabulary named like a D8 base field will be migrated and
45     // prefixed with 'field_' to avoid conflicts.
46     $field_type = FieldStorageConfig::load('node.field_type');
47     $this->assertInstanceOf(FieldStorageConfig::class, $field_type);
48   }
49
50 }