Pull merge.
[yaffs-website] / web / core / modules / taxonomy / tests / src / Kernel / Migrate / d7 / MigrateNodeTaxonomyTest.php
1 <?php
2
3 namespace Drupal\Tests\taxonomy\Kernel\Migrate\d7;
4
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;
11
12 /**
13  * @group taxonomy
14  */
15 class MigrateNodeTaxonomyTest extends MigrateDrupal7TestBase {
16
17   public static $modules = [
18     'datetime',
19     'field',
20     'filter',
21     'image',
22     'link',
23     'menu_ui',
24     'node',
25     'taxonomy',
26     'telephone',
27     'text',
28   ];
29
30   /**
31    * {@inheritdoc}
32    */
33   protected function setUp() {
34     parent::setUp();
35
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']);
41
42     $this->executeMigration('d7_node_type');
43
44     FieldStorageConfig::create([
45       'type' => 'entity_reference',
46       'field_name' => 'field_tags',
47       'entity_type' => 'node',
48       'settings' => [
49         'target_type' => 'taxonomy_term',
50       ],
51       'cardinality' => FieldStorageConfigInterface::CARDINALITY_UNLIMITED,
52     ])->save();
53
54     FieldConfig::create([
55       'entity_type' => 'node',
56       'field_name' => 'field_tags',
57       'bundle' => 'article',
58     ])->save();
59
60     $this->executeMigrations([
61       'd7_taxonomy_vocabulary',
62       'd7_taxonomy_term',
63       'd7_user_role',
64       'd7_user',
65       'd7_node:article',
66     ]);
67   }
68
69   /**
70    * Test node migration from Drupal 7 to 8.
71    */
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);
78   }
79
80 }