Newer
Older
Alex Pott
committed
<?php
/**
* @file
* Contains \Drupal\system\Tests\Update\UpdatePathTestBaseFilledTest.php
*/
namespace Drupal\system\Tests\Update;
use Drupal\node\Entity\Node;
use Drupal\user\Entity\User;
Alex Pott
committed
/**
* Runs UpdatePathTestBaseTest with a dump filled with content.
*
* @group Update
*/
class UpdatePathTestBaseFilledTest extends UpdatePathTestBaseTest {
/**
* {@inheritdoc}
*/
Angie Byron
committed
protected function setDatabaseDumpFiles() {
parent::setDatabaseDumpFiles();
Alex Pott
committed
$this->databaseDumpFiles[0] = __DIR__ . '/../../../tests/fixtures/update/drupal-8.filled.standard.php.gz';
}
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
/**
* Tests that the content and configuration were properly updated.
*/
public function testUpdatedSite() {
$this->runUpdates();
$spanish = \Drupal::languageManager()->getLanguage('es');
$expected_node_data = array(
[1, 'article', 'en', 'Test Article - New title'],
[2, 'book', 'en', 'Book page'],
[3, 'forum', 'en', 'Forum topic'],
[4, 'page', 'en', 'Test page'],
[8, 'test_content_type', 'en', 'Test title'],
);
foreach ($expected_node_data as $node_data) {
$id = $node_data[0];
$type = $node_data[1];
$langcode = $node_data[2];
$title = $node_data[3];
// Make sure our English nodes still exist.
$node = Node::load($id);
$this->assertEqual($node->language()->getId(), $langcode);
$this->assertEqual($node->getType(), $type);
$this->assertEqual($node->getTitle(), $title);
// Assert that nodes are all published.
$this->assertTrue($node->isPublished());
$this->drupalGet('node/' . $id);
$this->assertText($title);
}
// Make sure the translated node still exists.
$translation = Node::load(8)->getTranslation('es');
$this->assertEqual('Test title Spanish', $translation->getTitle());
// Make sure our alias still works.
$this->drupalGet('test-article');
$this->assertText('Test Article - New title');
$this->assertText('Body');
$this->assertText('Tags');
// Make sure a translated page exists.
$this->drupalGet('node/8', ['language' => $spanish]);
// Check for text of two comments.
$this->assertText('Hola');
$this->assertText('Hello');
// The user entity reference field is access restricted.
$this->assertNoText('Test 12');
// Make sure all other field labels are there.
for ($i = 1; $i <= 23; $i++) {
if ($i != 12) {
$this->assertText('Test ' . $i);
}
}
// Make sure the translated slogan appears.
$this->assertText('drupal Spanish');
// Make sure the custom block appears.
$this->drupalGet('<front>');
// Block title.
$this->assertText('Another block');
// Block body.
$this->assertText('Hello');
// Log in as user 1.
$account = User::load(1);
$account->pass_raw = 'drupal';
$this->drupalLogin($account);
// Make sure we can see the access-restricted entity reference field
// now that we're logged in.
$this->drupalGet('node/8', ['language' => $spanish]);
$this->assertText('Test 12');
$this->assertLink('drupal');
// Make sure the content for node 8 is still in the edit form.
$this->drupalGet('node/8/edit');
$this->assertText('Test title');
$this->assertText('Test body');
$this->assertFieldChecked('edit-field-test-1-value');
$this->assertRaw('2015-08-16');
$this->assertRaw('test@example.com');
$this->assertRaw('drupal.org');
$this->assertText('0.1');
$this->assertText('0.2');
$this->assertRaw('+31612345678');
$this->assertRaw('+31612345679');
$this->assertText('Test Article - New title');
$this->assertText('test.txt');
$this->assertText('druplicon.small');
$this->assertRaw('General discussion');
$this->assertText('Test Article - New title');
$this->assertText('Test 1');
$this->assertRaw('0.01');
$this->drupalPostForm('node/8/edit', [], 'Save and keep published (this translation)');
$this->assertResponse(200);
$this->drupalGet('node/8/edit', ['language' => $spanish]);
$this->assertText('Test title Spanish');
$this->assertText('Test body Spanish');
// Make sure the user page is correct.
$this->drupalGet('user/3');
$this->assertText('usuario_test');
$this->assertRaw('druplicon.small');
$this->assertText('Test file field');
$this->assertLink('test.txt');
// Make sure the user is translated.
$this->drupalGet('user/3/translations');
$this->assertNoText('Not translated');
// Make sure the custom field on the user is still there.
$this->drupalGet('admin/config/people/accounts/fields');
$this->assertText('Test file field');
// Make sure the test view still exists.
$this->drupalGet('admin/structure/views/view/test_view');
$this->assertText('Test view');
// Make sure the book node exists.
$this->drupalGet('admin/structure/book');
$this->clickLink('Test Article - New title');
$this->assertText('Body');
$this->assertText('Tags');
$this->assertRaw('Text format');
// Make sure that users still exist.
$this->drupalGet('admin/people');
$this->assertText('usuario_test');
$this->assertText('drupal');
$this->drupalGet('user/1/edit');
$this->assertRaw('drupal@example.com');
// Make sure the content view works.
$this->drupalGet('admin/content');
$this->assertText('Test title');
// Make sure our custom blocks show up.
$this->drupalGet('admin/structure/block');
$this->assertText('Another block');
$this->assertText('Test block');
$this->drupalGet('admin/structure/block/block-content');
$this->assertText('Another block');
$this->assertText('Test block');
// Make sure our custom visibility conditions are correct.
$this->drupalGet('admin/structure/block/manage/testblock');
$this->assertNoFieldChecked('edit-visibility-language-langcodes-es');
$this->assertFieldChecked('edit-visibility-language-langcodes-en');
$this->assertNoFieldChecked('edit-visibility-node-type-bundles-book');
$this->assertFieldChecked('edit-visibility-node-type-bundles-test-content-type');
// Make sure our block is still translated.
$this->drupalGet('admin/structure/block/manage/testblock/translate/es/edit');
$this->assertRaw('Test block spanish');
// Make sure our custom text format exists.
$this->drupalGet('admin/config/content/formats');
$this->assertText('Test text format');
$this->drupalGet('admin/config/content/formats/manage/test_text_format');
$this->assertResponse('200');
// Make sure our feed still exists.
$this->drupalGet('admin/config/services/aggregator');
$this->assertText('Test feed');
$this->drupalGet('admin/config/services/aggregator/fields');
$this->assertText('field_test');
// Make sure our view appears in the overview.
$this->drupalGet('admin/structure/views');
$this->assertText('test_view');
$this->assertText('Test view');
// Make sure our custom forum exists.
$this->drupalGet('admin/structure/forum');
$this->assertText('Test forum');
// Make sure our custom menu exists.
$this->drupalGet('admin/structure/menu');
$this->assertText('Test menu');
// Make sure our custom menu exists.
$this->drupalGet('admin/structure/menu/manage/test-menu');
$this->clickLink('Admin');
// Make sure the translation for the menu is still correct.
$this->drupalGet('admin/structure/menu/manage/test-menu/translate/es/edit');
$this->assertRaw('Menu test');
// Make sure our custom menu link exists.
$this->drupalGet('admin/structure/menu/item/1/edit');
$this->assertFieldChecked('edit-enabled-value');
// Make sure our comment type exists.
$this->drupalGet('admin/structure/comment');
$this->assertText('Test comment type');
$this->drupalGet('admin/structure/comment/manage/test_comment_type/fields');
$this->assertText('comment_body');
// Make sure our contact form exists.
$this->drupalGet('admin/structure/contact');
$this->assertText('Test contact form');
$this->drupalGet('admin/structure/types');
$this->assertText('Test content type description');
$this->drupalGet('admin/structure/types/manage/test_content_type/fields');
// Make sure fields are the right type.
$this->assertLink('Text (formatted, long, with summary)');
$this->assertLink('Boolean');
$this->assertLink('Comments');
$this->assertLink('Date');
$this->assertLink('Email');
$this->assertLink('Link');
$this->assertLink('List (float)');
$this->assertLink('Telephone number');
$this->assertLink('Entity reference');
$this->assertLink('File');
$this->assertLink('Image');
$this->assertLink('Text (plain, long)');
$this->assertLink('List (text)');
$this->assertLink('Text (formatted, long)');
$this->assertLink('Text (plain)');
$this->assertLink('List (integer)');
$this->assertLink('Number (integer)');
$this->assertLink('Number (float)');
// Make sure our form mode exists.
$this->drupalGet('admin/structure/display-modes/form');
$this->assertText('New form mode');
// Make sure our view mode exists.
$this->drupalGet('admin/structure/display-modes/view');
$this->assertText('New view mode');
$this->drupalGet('admin/structure/display-modes/view/manage/node.new_view_mode');
$this->assertResponse(200);
// Make sure our other language is still there.
$this->drupalGet('admin/config/regional/language');
$this->assertText('Spanish');
// Make sure our custom date format exists.
$this->drupalGet('admin/config/regional/date-time');
$this->assertText('Test date format');
$this->drupalGet('admin/config/regional/date-time/formats/manage/test_date_format');
$this->assertOptionSelected('edit-langcode', 'es');
// Make sure our custom image style exists.
$this->drupalGet('admin/config/media/image-styles/manage/test_image_style');
$this->assertText('Test image style');
$this->assertText('Desaturate');
$this->assertText('Convert PNG');
// Make sure our custom responsive image style exists.
$this->drupalGet('admin/config/media/responsive-image-style/test');
$this->assertResponse(200);
$this->assertText('Test');
// Make sure our custom shortcut exists.
$this->drupalGet('admin/config/user-interface/shortcut');
$this->assertText('Test shortcut');
$this->drupalGet('admin/config/user-interface/shortcut/manage/test/customize');
$this->assertText('All content');
// Make sure our language detection settings are still correct.
$this->drupalGet('admin/config/regional/language/detection');
$this->assertFieldChecked('edit-language-interface-enabled-language-user-admin');
$this->assertFieldChecked('edit-language-interface-enabled-language-url');
$this->assertFieldChecked('edit-language-interface-enabled-language-session');
$this->assertFieldChecked('edit-language-interface-enabled-language-user');
$this->assertFieldChecked('edit-language-interface-enabled-language-browser');
// Make sure strings are still translated.
$this->drupalGet('admin/structure/views/view/content/translate/es/edit');
$this->assertText('Contenido');
$this->drupalPostForm('admin/config/regional/translate', ['string' => 'Full comment'], 'Filter');
$this->assertText('Comentario completo');
// Make sure our custom action is still there.
$this->drupalGet('admin/config/system/actions');
$this->assertText('Test action');
$this->drupalGet('admin/config/system/actions/configure/test_action');
$this->assertText('test_action');
$this->assertRaw('drupal.org');
// Make sure our ban still exists.
$this->drupalGet('admin/config/people/ban');
$this->assertText('8.8.8.8');
// Make sure our vocabulary exists.
$this->drupalGet('admin/structure/taxonomy/manage/test_vocabulary/overview');
// Make sure our terms exist.
$this->assertText('Test root term');
$this->assertText('Test child term');
$this->drupalGet('taxonomy/term/3');
$this->assertResponse('200');
// Make sure the terms are still translated.
$this->drupalGet('taxonomy/term/2/translations');
$this->assertLink('Test root term - Spanish');
// Make sure our contact form exists.
$this->drupalGet('admin/structure/contact');
$this->assertText('Test contact form');
$this->drupalGet('admin/structure/contact/manage/test_contact_form');
$this->assertText('test@example.com');
$this->assertText('Hello');
$this->drupalGet('admin/structure/contact/manage/test_contact_form/translate/es/edit');
$this->assertText('Hola');
$this->assertRaw('Test contact form Spanish');
// Make sure our modules are still enabled.
$expected_enabled_modules = [
'action',
'aggregator',
'ban',
'basic_auth',
'block',
'block_content',
'book',
'breakpoint',
'ckeditor',
'color',
'comment',
'config',
'config_translation',
'contact',
'content_translation',
'contextual',
'datetime',
'dblog',
'editor',
'entity_reference',
'field',
'field_ui',
'file',
'filter',
'hal',
'help',
'history',
'image',
'language',
'link',
'locale',
'menu_ui',
'migrate',
'migrate_drupal',
'node',
'options',
'page_cache',
'path',
'quickedit',
'rdf',
'responsive_image',
'rest',
'search',
'serialization',
'shortcut',
'simpletest',
'statistics',
'syslog',
'system',
'taxonomy',
'telephone',
'text',
'toolbar',
'tour',
'tracker',
'update',
'user',
'views_ui',
'forum',
'menu_link_content',
'views',
'standard',
];
foreach ($expected_enabled_modules as $module) {
$this->assertTrue($this->container->get('module_handler')->moduleExists($module), 'The "' . $module . '" module is still enabled.');
}
// Make sure our themes are still enabled.
$expected_enabled_themes = [
'bartik',
'classy',
'seven',
'stark',
];
foreach ($expected_enabled_themes as $theme) {
$this->assertTrue($this->container->get('theme_handler')->themeExists($theme), 'The "' . $theme . '" is still enabled.');
}
}
/**
* {@inheritdoc}
*/
protected function replaceUser1() {
// Do not replace the user from our dump.
}