3 namespace Drupal\Tests\taxonomy\Kernel\Migrate\d7;
5 use Drupal\field\Entity\FieldConfig;
6 use Drupal\field\Entity\FieldStorageConfig;
7 use Drupal\field\FieldStorageConfigInterface;
8 use Drupal\Tests\migrate_drupal\Kernel\d7\MigrateDrupal7TestBase;
9 use Drupal\node\Entity\Node;
10 use Drupal\node\NodeInterface;
15 class MigrateNodeTaxonomyTest extends MigrateDrupal7TestBase {
17 public static $modules = [
33 protected function setUp() {
36 $this->installEntitySchema('node');
37 $this->installEntitySchema('taxonomy_term');
38 $this->installConfig(static::$modules);
39 $this->installSchema('node', ['node_access']);
40 $this->installSchema('system', ['sequences']);
42 $this->executeMigration('d7_node_type');
44 FieldStorageConfig::create([
45 'type' => 'entity_reference',
46 'field_name' => 'field_tags',
47 'entity_type' => 'node',
49 'target_type' => 'taxonomy_term',
51 'cardinality' => FieldStorageConfigInterface::CARDINALITY_UNLIMITED,
55 'entity_type' => 'node',
56 'field_name' => 'field_tags',
57 'bundle' => 'article',
60 $this->executeMigrations([
61 'd7_taxonomy_vocabulary',
70 * Test node migration from Drupal 7 to 8.
72 public function testMigration() {
73 $node = Node::load(2);
74 $this->assertTrue($node instanceof NodeInterface);
75 $this->assertEqual(9, $node->field_tags[0]->target_id);
76 $this->assertEqual(14, $node->field_tags[1]->target_id);
77 $this->assertEqual(17, $node->field_tags[2]->target_id);