b1718011f0917e6e1097288c7df2d6a85461ec4c
[yaffs-website] / web / core / modules / migrate_drupal_ui / tests / src / Functional / d7 / MigrateUpgrade7Test.php
1 <?php
2
3 namespace Drupal\Tests\migrate_drupal_ui\Functional\d7;
4
5 use Drupal\node\Entity\Node;
6 use Drupal\Tests\migrate_drupal_ui\Functional\MigrateUpgradeExecuteTestBase;
7 use Drupal\user\Entity\User;
8
9 /**
10  * Tests Drupal 7 upgrade using the migrate UI.
11  *
12  * The test method is provided by the MigrateUpgradeTestBase class.
13  *
14  * @group migrate_drupal_ui
15  */
16 class MigrateUpgrade7Test extends MigrateUpgradeExecuteTestBase {
17
18   /**
19    * Modules to enable.
20    *
21    * @var array
22    */
23   public static $modules = [
24     'file',
25     'language',
26     'config_translation',
27     'content_translation',
28     'migrate_drupal_ui',
29     'telephone',
30     'aggregator',
31     'book',
32     'forum',
33     'rdf',
34     'statistics',
35     'migration_provider_test',
36     // Required for translation migrations.
37     'migrate_drupal_multilingual',
38   ];
39
40   /**
41    * {@inheritdoc}
42    */
43   protected function setUp() {
44     parent::setUp();
45     $this->loadFixture(drupal_get_path('module', 'migrate_drupal') . '/tests/fixtures/drupal7.php');
46   }
47
48   /**
49    * {@inheritdoc}
50    */
51   protected function getSourceBasePath() {
52     return __DIR__ . '/files';
53   }
54
55   /**
56    * {@inheritdoc}
57    */
58   protected function getEntityCounts() {
59     return [
60       'aggregator_item' => 11,
61       'aggregator_feed' => 1,
62       'block' => 25,
63       'block_content' => 1,
64       'block_content_type' => 1,
65       'comment' => 3,
66       // The 'standard' profile provides the 'comment' comment type, and the
67       // migration creates 6 comment types, one per node type.
68       'comment_type' => 7,
69       // Module 'language' comes with 'en', 'und', 'zxx'. Migration adds 'is'
70       // and 'fr'.
71       'configurable_language' => 5,
72       'contact_form' => 3,
73       'editor' => 2,
74       'field_config' => 67,
75       'field_storage_config' => 50,
76       'file' => 3,
77       'filter_format' => 7,
78       'image_style' => 6,
79       'language_content_settings' => 6,
80       'migration' => 73,
81       'node' => 5,
82       'node_type' => 6,
83       'rdf_mapping' => 8,
84       'search_page' => 2,
85       'shortcut' => 6,
86       'shortcut_set' => 2,
87       'action' => 17,
88       'menu' => 6,
89       'taxonomy_term' => 18,
90       'taxonomy_vocabulary' => 4,
91       'tour' => 5,
92       'user' => 4,
93       'user_role' => 3,
94       'menu_link_content' => 12,
95       'view' => 16,
96       'date_format' => 11,
97       'entity_form_display' => 17,
98       'entity_form_mode' => 1,
99       'entity_view_display' => 28,
100       'entity_view_mode' => 14,
101       'base_field_override' => 9,
102     ];
103   }
104
105   /**
106    * {@inheritdoc}
107    */
108   protected function getEntityCountsIncremental() {
109     $counts = $this->getEntityCounts();
110     $counts['block_content'] = 2;
111     $counts['comment'] = 4;
112     $counts['file'] = 4;
113     $counts['menu_link_content'] = 13;
114     $counts['node'] = 6;
115     $counts['taxonomy_term'] = 19;
116     $counts['user'] = 5;
117     return $counts;
118   }
119
120   /**
121    * {@inheritdoc}
122    */
123   protected function getAvailablePaths() {
124     return [
125       'aggregator',
126       'block',
127       'book',
128       'color',
129       'comment',
130       'contact',
131       'date',
132       'dblog',
133       'email',
134       'entityreference',
135       'field',
136       'field_sql_storage',
137       'file',
138       'filter',
139       'forum',
140       'i18n_variable',
141       'image',
142       'language',
143       'link',
144       'list',
145       'locale',
146       'menu',
147       'node',
148       'number',
149       'options',
150       'path',
151       'phone',
152       'rdf',
153       'search',
154       'shortcut',
155       'statistics',
156       'system',
157       'taxonomy',
158       'text',
159       'user',
160       // Include modules that do not have an upgrade path and are enabled in the
161       // source database, defined in the $noUpgradePath property
162       // in MigrateUpgradeForm.
163       'blog',
164       'contextual',
165       'date_api',
166       'entity',
167       'field_ui',
168       'help',
169       'php',
170       'simpletest',
171       'toolbar',
172       'translation',
173       'trigger',
174     ];
175   }
176
177   /**
178    * {@inheritdoc}
179    */
180   protected function getMissingPaths() {
181     return [
182       'i18n',
183       'variable',
184       'variable_realm',
185       'variable_store',
186       // These modules are in the missing path list because they are installed
187       // on the source site but they are not installed on the destination site.
188       'syslog',
189       'tracker',
190       'update',
191     ];
192   }
193
194   /**
195    * Executes all steps of migrations upgrade.
196    */
197   public function testMigrateUpgradeExecute() {
198     parent::testMigrateUpgradeExecute();
199
200     // Ensure migrated users can log in.
201     $user = User::load(2);
202     $user->passRaw = 'a password';
203     $this->drupalLogin($user);
204     $this->assertFollowUpMigrationResults();
205   }
206
207   /**
208    * Tests that follow-up migrations have been run successfully.
209    */
210   protected function assertFollowUpMigrationResults() {
211     $node = Node::load(2);
212     $this->assertSame('4', $node->get('field_reference')->target_id);
213     $this->assertSame('4', $node->get('field_reference_2')->target_id);
214     $translation = $node->getTranslation('is');
215     $this->assertSame('4', $translation->get('field_reference')->target_id);
216     $this->assertSame('4', $translation->get('field_reference_2')->target_id);
217
218     $node = Node::load(4);
219     $this->assertSame('2', $node->get('field_reference')->target_id);
220     $this->assertSame('2', $node->get('field_reference_2')->target_id);
221     $translation = $node->getTranslation('en');
222     $this->assertSame('2', $translation->get('field_reference')->target_id);
223     $this->assertSame('2', $translation->get('field_reference_2')->target_id);
224
225   }
226
227 }