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