Version 1
[yaffs-website] / web / core / modules / migrate_drupal / tests / src / Kernel / d6 / MigrateDrupal6TestBase.php
1 <?php
2
3 namespace Drupal\Tests\migrate_drupal\Kernel\d6;
4
5 use Drupal\Tests\migrate_drupal\Kernel\MigrateDrupalTestBase;
6
7 /**
8  * Base class for Drupal 6 migration tests.
9  */
10 abstract class MigrateDrupal6TestBase extends MigrateDrupalTestBase {
11
12   /**
13    * {@inheritdoc}
14    */
15   public static $modules = [
16     'datetime',
17     'filter',
18     'image',
19     'link',
20     'node',
21     'options',
22     'telephone',
23     'text',
24   ];
25
26   /**
27    * {@inheritdoc}
28    */
29   protected function setUp() {
30     parent::setUp();
31     $this->loadFixture($this->getFixtureFilePath());
32   }
33
34   /**
35    * Gets the path to the fixture file.
36    */
37   protected function getFixtureFilePath() {
38     return __DIR__ . '/../../../fixtures/drupal6.php';
39   }
40
41   /**
42    * Executes all user migrations.
43    *
44    * @param bool $include_pictures
45    *   If TRUE, migrates user pictures.
46    */
47   protected function migrateUsers($include_pictures = TRUE) {
48     $this->executeMigrations(['d6_filter_format', 'd6_user_role']);
49
50     if ($include_pictures) {
51       $this->installEntitySchema('file');
52       $this->executeMigrations([
53         'd6_file',
54         'd6_user_picture_file',
55         'user_picture_field',
56         'user_picture_field_instance',
57         'user_picture_entity_display',
58         'user_picture_entity_form_display',
59       ]);
60     }
61
62     $this->executeMigration('d6_user');
63   }
64
65   /**
66    * Migrates node types.
67    */
68   protected function migrateContentTypes() {
69     $this->installConfig(['node']);
70     $this->executeMigration('d6_node_type');
71   }
72
73   /**
74    * Executes all field migrations.
75    */
76   protected function migrateFields() {
77     $this->migrateContentTypes();
78     $this->executeMigrations([
79       'd6_field',
80       'd6_field_instance',
81       'd6_field_instance_widget_settings',
82       'd6_view_modes',
83       'd6_field_formatter_settings',
84       'd6_upload_field',
85       'd6_upload_field_instance',
86     ]);
87   }
88
89   /**
90    * Executes all content migrations.
91    *
92    * @param array $include
93    *   Extra things to include as part of the migrations. Values may be
94    *   'revisions' or 'translations'.
95    */
96   protected function migrateContent($include = []) {
97     if (in_array('translations', $include)) {
98       $this->executeMigrations(['language']);
99     }
100     $this->migrateUsers(FALSE);
101     $this->migrateFields();
102
103     $this->installEntitySchema('node');
104     $this->executeMigrations(['d6_node_settings', 'd6_node']);
105
106     if (in_array('translations', $include)) {
107       $this->executeMigrations(['translations']);
108     }
109     if (in_array('revisions', $include)) {
110       $this->executeMigrations(['d6_node_revision']);
111     }
112   }
113
114   /**
115    * Executes all taxonomy migrations.
116    */
117   protected function migrateTaxonomy() {
118     $this->migrateContentTypes();
119     $this->installEntitySchema('taxonomy_term');
120     $this->executeMigrations([
121       'd6_taxonomy_vocabulary',
122       'd6_vocabulary_field',
123       'd6_vocabulary_field_instance',
124       'd6_vocabulary_entity_display',
125       'd6_vocabulary_entity_form_display',
126       'd6_taxonomy_term',
127     ]);
128   }
129
130 }