e07e8bf211f7c1547d4a6c4430abee879f5bb558
[yaffs-website] / web / core / modules / migrate_drupal_ui / tests / src / Functional / d6 / MigrateUpgrade6NoMultilingualTest.php
1 <?php
2
3 namespace Drupal\Tests\migrate_drupal_ui\Functional\d6;
4
5 use Drupal\Tests\migrate_drupal_ui\Functional\MigrateUpgradeExecuteTestBase;
6
7 /**
8  * Tests Drupal 6 upgrade without translations.
9  *
10  * The test method is provided by the MigrateUpgradeTestBase class.
11  *
12  * @group migrate_drupal_ui
13  */
14 class MigrateUpgrade6NoMultilingualTest extends MigrateUpgradeExecuteTestBase {
15
16   /**
17    * {@inheritdoc}
18    */
19   public static $modules = [
20     'language',
21     'content_translation',
22     'config_translation',
23     'migrate_drupal_ui',
24     'telephone',
25     'aggregator',
26     'book',
27     'forum',
28     'statistics',
29   ];
30
31   /**
32    * {@inheritdoc}
33    */
34   protected function setUp() {
35     parent::setUp();
36     $this->loadFixture(drupal_get_path('module', 'migrate_drupal') . '/tests/fixtures/drupal6.php');
37   }
38
39   /**
40    * {@inheritdoc}
41    */
42   protected function getSourceBasePath() {
43     return __DIR__ . '/files';
44   }
45
46   /**
47    * {@inheritdoc}
48    */
49   protected function getEntityCounts() {
50     return [
51       'aggregator_item' => 1,
52       'aggregator_feed' => 2,
53       'block' => 35,
54       'block_content' => 2,
55       'block_content_type' => 1,
56       'comment' => 6,
57       // The 'standard' profile provides the 'comment' comment type, and the
58       // migration creates 12 comment types, one per node type.
59       'comment_type' => 13,
60       'contact_form' => 5,
61       'configurable_language' => 5,
62       'editor' => 2,
63       'field_config' => 89,
64       'field_storage_config' => 63,
65       'file' => 8,
66       'filter_format' => 7,
67       'image_style' => 5,
68       'language_content_settings' => 3,
69       'migration' => 105,
70       'node' => 17,
71       // The 'book' module provides the 'book' node type, and the migration
72       // creates 12 node types.
73       'node_type' => 13,
74       'rdf_mapping' => 7,
75       'search_page' => 2,
76       'shortcut' => 2,
77       'shortcut_set' => 1,
78       'action' => 23,
79       'menu' => 8,
80       'taxonomy_term' => 8,
81       'taxonomy_vocabulary' => 7,
82       'tour' => 4,
83       'user' => 7,
84       'user_role' => 6,
85       'menu_link_content' => 8,
86       'view' => 16,
87       'date_format' => 11,
88       'entity_form_display' => 29,
89       'entity_form_mode' => 1,
90       'entity_view_display' => 55,
91       'entity_view_mode' => 14,
92       'base_field_override' => 38,
93     ];
94   }
95
96   /**
97    * {@inheritdoc}
98    */
99   protected function getEntityCountsIncremental() {
100     $counts = $this->getEntityCounts();
101     $counts['block_content'] = 3;
102     $counts['comment'] = 7;
103     $counts['file'] = 9;
104     $counts['menu_link_content'] = 9;
105     $counts['node'] = 18;
106     $counts['taxonomy_term'] = 9;
107     $counts['user'] = 8;
108     $counts['view'] = 16;
109     return $counts;
110   }
111
112   /**
113    * {@inheritdoc}
114    */
115   protected function getAvailablePaths() {
116     return [
117       'aggregator',
118       'block',
119       'book',
120       'comment',
121       'contact',
122       'content',
123       'date',
124       'dblog',
125       'email',
126       'filefield',
127       'filter',
128       'forum',
129       'imagecache',
130       'imagefield',
131       'language',
132       'link',
133       'locale',
134       'menu',
135       'node',
136       'nodereference',
137       'optionwidgets',
138       'path',
139       'profile',
140       'search',
141       'statistics',
142       'system',
143       'taxonomy',
144       'text',
145       'upload',
146       'user',
147       'userreference',
148       // Include modules that do not have an upgrade path and are enabled in the
149       // source database, defined in the $noUpgradePath property
150       // in MigrateUpgradeForm.
151       'date_api',
152       'date_timezone',
153       'event',
154       'i18n',
155       'i18nstrings',
156       'imageapi',
157       'number',
158       'php',
159       'profile',
160       'variable_admin',
161     ];
162   }
163
164   /**
165    * {@inheritdoc}
166    */
167   protected function getMissingPaths() {
168     return [
169       'i18nblocks',
170       'i18ncck',
171       'i18ncontent',
172       'i18nmenu',
173       'i18nprofile',
174     ];
175   }
176
177   /**
178    * {@inheritdoc}
179    */
180   public function testMigrateUpgradeExecute() {
181     $connection_options = $this->sourceDatabase->getConnectionOptions();
182     $this->drupalGet('/upgrade');
183     $session = $this->assertSession();
184     $session->responseContains('Upgrade a site by importing its files and the data from its database into a clean and empty new install of Drupal 8.');
185
186     $button = $session->buttonExists('Continue');
187     $button->click();
188     $session->pageTextContains('Provide credentials for the database of the Drupal site you want to upgrade.');
189
190     $driver = $connection_options['driver'];
191     $connection_options['prefix'] = $connection_options['prefix']['default'];
192
193     // Use the driver connection form to get the correct options out of the
194     // database settings. This supports all of the databases we test against.
195     $drivers = drupal_get_database_types();
196     $form = $drivers[$driver]->getFormOptions($connection_options);
197     $connection_options = array_intersect_key($connection_options, $form + $form['advanced_options']);
198     $version = $this->getLegacyDrupalVersion($this->sourceDatabase);
199     $edit = [
200       $driver => $connection_options,
201       'version' => $version,
202     ];
203     if (count($drivers) !== 1) {
204       $edit['driver'] = $driver;
205     }
206     $edits = $this->translatePostValues($edit);
207     $this->drupalPostForm(NULL, $edits, t('Review upgrade'));
208     $session->pageTextContains("Install migrate_drupal_multilingual to run migration 'd6_system_maintenance_translation'.");
209   }
210
211 }