3 namespace Drupal\Tests\system\Functional\Update;
5 use Drupal\FunctionalTests\Update\UpdatePathTestBaseTest;
6 use Drupal\node\Entity\Node;
7 use Drupal\node\Entity\NodeType;
8 use Drupal\user\Entity\User;
11 * Runs UpdatePathTestBaseTest with a dump filled with content.
16 class UpdatePathTestBaseFilledTest extends UpdatePathTestBaseTest {
21 protected function setDatabaseDumpFiles() {
22 parent::setDatabaseDumpFiles();
23 $this->databaseDumpFiles[0] = __DIR__ . '/../../../../tests/fixtures/update/drupal-8.filled.standard.php.gz';
27 * Tests that the content and configuration were properly updated.
29 public function testUpdatedSite() {
32 $spanish = \Drupal::languageManager()->getLanguage('es');
34 $expected_node_data = [
35 [1, 'article', 'en', 'Test Article - New title'],
36 [2, 'book', 'en', 'Book page'],
37 [3, 'forum', 'en', 'Forum topic'],
38 [4, 'page', 'en', 'Test page'],
39 [8, 'test_content_type', 'en', 'Test title'],
41 foreach ($expected_node_data as $node_data) {
43 $type = $node_data[1];
44 $langcode = $node_data[2];
45 $title = $node_data[3];
47 // Make sure our English nodes still exist.
48 $node = Node::load($id);
49 $this->assertEqual($node->language()->getId(), $langcode);
50 $this->assertEqual($node->getType(), $type);
51 $this->assertEqual($node->getTitle(), $title);
52 // Assert that nodes are all published.
53 $this->assertTrue($node->isPublished());
54 $this->drupalGet('node/' . $id);
55 $this->assertText($title);
58 // Make sure the translated node still exists.
59 $translation = Node::load(8)->getTranslation('es');
60 $this->assertEqual('Test title Spanish', $translation->getTitle());
62 // Make sure our alias still works.
63 $this->drupalGet('test-article');
64 $this->assertText('Test Article - New title');
65 $this->assertText('Body');
66 $this->assertText('Tags');
68 // Make sure a translated page exists.
69 $this->drupalGet('node/8', ['language' => $spanish]);
70 // Check for text of two comments.
71 $this->assertText('Hola');
72 $this->assertText('Hello');
73 // The user entity reference field is access restricted.
74 $this->assertNoText('Test 12');
75 // Make sure all other field labels are there.
76 for ($i = 1; $i <= 23; $i++) {
78 $this->assertText('Test ' . $i);
82 // Make sure the translated slogan appears.
83 $this->assertText('drupal Spanish');
85 // Make sure the custom block appears.
86 $this->drupalGet('<front>');
88 $this->assertText('Another block');
90 $this->assertText('Hello');
93 $account = User::load(1);
94 $account->passRaw = 'drupal';
95 $this->drupalLogin($account);
97 // Make sure we can see the access-restricted entity reference field
98 // now that we're logged in.
99 $this->drupalGet('node/8', ['language' => $spanish]);
100 $this->assertText('Test 12');
101 $this->assertLink('drupal');
103 // Make sure the content for node 8 is still in the edit form.
104 $this->drupalGet('node/8/edit');
105 $this->assertText('Test title');
106 $this->assertText('Test body');
107 $this->assertFieldChecked('edit-field-test-1-value');
108 $this->assertRaw('2015-08-16');
109 $this->assertRaw('test@example.com');
110 $this->assertRaw('drupal.org');
111 $this->assertText('0.1');
112 $this->assertText('0.2');
113 $this->assertRaw('+31612345678');
114 $this->assertRaw('+31612345679');
115 $this->assertText('Test Article - New title');
116 $this->assertText('test.txt');
117 $this->assertText('druplicon.small');
118 $this->assertRaw('General discussion');
119 $this->assertText('Test Article - New title');
120 $this->assertText('Test 1');
121 $this->assertRaw('0.01');
122 $this->drupalPostForm('node/8/edit', [], 'Save (this translation)');
123 $this->assertResponse(200);
124 $this->drupalGet('node/8/edit', ['language' => $spanish]);
125 $this->assertText('Test title Spanish');
126 $this->assertText('Test body Spanish');
128 // Make sure the user page is correct.
129 $this->drupalGet('user/3');
130 $this->assertText('usuario_test');
131 $this->assertRaw('druplicon.small');
132 $this->assertText('Test file field');
133 $this->assertLink('test.txt');
135 // Make sure the user is translated.
136 $this->drupalGet('user/3/translations');
137 $this->assertNoText('Not translated');
139 // Make sure the custom field on the user is still there.
140 $this->drupalGet('admin/config/people/accounts/fields');
141 $this->assertText('Test file field');
143 // Make sure the test view still exists.
144 $this->drupalGet('admin/structure/views/view/test_view');
145 $this->assertText('Test view');
147 // Make sure the book node exists.
148 $this->drupalGet('admin/structure/book');
149 $this->clickLink('Test Article - New title');
150 $this->assertText('Body');
151 $this->assertText('Tags');
152 $this->assertRaw('Text format');
154 // Make sure that users still exist.
155 $this->drupalGet('admin/people');
156 $this->assertText('usuario_test');
157 $this->assertText('drupal');
158 $this->drupalGet('user/1/edit');
159 $this->assertRaw('drupal@example.com');
161 // Make sure the content view works.
162 $this->drupalGet('admin/content');
163 $this->assertText('Test title');
165 // Make sure our custom blocks show up.
166 $this->drupalGet('admin/structure/block');
167 $this->assertText('Another block');
168 $this->assertText('Test block');
169 $this->drupalGet('admin/structure/block/block-content');
170 $this->assertText('Another block');
171 $this->assertText('Test block');
173 // Make sure our custom visibility conditions are correct.
174 $this->drupalGet('admin/structure/block/manage/testblock');
175 $this->assertNoFieldChecked('edit-visibility-language-langcodes-es');
176 $this->assertFieldChecked('edit-visibility-language-langcodes-en');
177 $this->assertNoFieldChecked('edit-visibility-node-type-bundles-book');
178 $this->assertFieldChecked('edit-visibility-node-type-bundles-test-content-type');
180 // Make sure our block is still translated.
181 $this->drupalGet('admin/structure/block/manage/testblock/translate/es/edit');
182 $this->assertRaw('Test block spanish');
184 // Make sure our custom text format exists.
185 $this->drupalGet('admin/config/content/formats');
186 $this->assertText('Test text format');
187 $this->drupalGet('admin/config/content/formats/manage/test_text_format');
188 $this->assertResponse('200');
190 // Make sure our feed still exists.
191 $this->drupalGet('admin/config/services/aggregator');
192 $this->assertText('Test feed');
193 $this->drupalGet('admin/config/services/aggregator/fields');
194 $this->assertText('field_test');
196 // Make sure our view appears in the overview.
197 $this->drupalGet('admin/structure/views');
198 $this->assertText('test_view');
199 $this->assertText('Test view');
201 // Make sure our custom forum exists.
202 $this->drupalGet('admin/structure/forum');
203 $this->assertText('Test forum');
205 // Make sure our custom menu exists.
206 $this->drupalGet('admin/structure/menu');
207 $this->assertText('Test menu');
209 // Make sure our custom menu exists.
210 $this->drupalGet('admin/structure/menu/manage/test-menu');
211 $this->clickLink('Admin');
212 // Make sure the translation for the menu is still correct.
213 $this->drupalGet('admin/structure/menu/manage/test-menu/translate/es/edit');
214 $this->assertRaw('Menu test');
215 // Make sure our custom menu link exists.
216 $this->drupalGet('admin/structure/menu/item/1/edit');
217 $this->assertFieldChecked('edit-enabled-value');
219 // Make sure our comment type exists.
220 $this->drupalGet('admin/structure/comment');
221 $this->assertText('Test comment type');
222 $this->drupalGet('admin/structure/comment/manage/test_comment_type/fields');
223 $this->assertText('comment_body');
225 // Make sure our contact form exists.
226 $this->drupalGet('admin/structure/contact');
227 $this->assertText('Test contact form');
228 $this->drupalGet('admin/structure/types');
229 $this->assertText('Test content type description');
230 $this->drupalGet('admin/structure/types/manage/test_content_type/fields');
232 // Make sure fields are the right type.
233 $this->assertLink('Text (formatted, long, with summary)');
234 $this->assertLink('Boolean');
235 $this->assertLink('Comments');
236 $this->assertLink('Date');
237 $this->assertLink('Email');
238 $this->assertLink('Link');
239 $this->assertLink('List (float)');
240 $this->assertLink('Telephone number');
241 $this->assertLink('Entity reference');
242 $this->assertLink('File');
243 $this->assertLink('Image');
244 $this->assertLink('Text (plain, long)');
245 $this->assertLink('List (text)');
246 $this->assertLink('Text (formatted, long)');
247 $this->assertLink('Text (plain)');
248 $this->assertLink('List (integer)');
249 $this->assertLink('Number (integer)');
250 $this->assertLink('Number (float)');
252 // Make sure our form mode exists.
253 $this->drupalGet('admin/structure/display-modes/form');
254 $this->assertText('New form mode');
256 // Make sure our view mode exists.
257 $this->drupalGet('admin/structure/display-modes/view');
258 $this->assertText('New view mode');
259 $this->drupalGet('admin/structure/display-modes/view/manage/node.new_view_mode');
260 $this->assertResponse(200);
262 // Make sure our other language is still there.
263 $this->drupalGet('admin/config/regional/language');
264 $this->assertText('Spanish');
266 // Make sure our custom date format exists.
267 $this->drupalGet('admin/config/regional/date-time');
268 $this->assertText('Test date format');
269 $this->drupalGet('admin/config/regional/date-time/formats/manage/test_date_format');
270 $this->assertOptionSelected('edit-langcode', 'es');
272 // Make sure our custom image style exists.
273 $this->drupalGet('admin/config/media/image-styles/manage/test_image_style');
274 $this->assertText('Test image style');
275 $this->assertText('Desaturate');
276 $this->assertText('Convert PNG');
278 // Make sure our custom responsive image style exists.
279 $this->drupalGet('admin/config/media/responsive-image-style/test');
280 $this->assertResponse(200);
281 $this->assertText('Test');
283 // Make sure our custom shortcut exists.
284 $this->drupalGet('admin/config/user-interface/shortcut');
285 $this->assertText('Test shortcut');
286 $this->drupalGet('admin/config/user-interface/shortcut/manage/test/customize');
287 $this->assertText('All content');
289 // Make sure our language detection settings are still correct.
290 $this->drupalGet('admin/config/regional/language/detection');
291 $this->assertFieldChecked('edit-language-interface-enabled-language-user-admin');
292 $this->assertFieldChecked('edit-language-interface-enabled-language-url');
293 $this->assertFieldChecked('edit-language-interface-enabled-language-session');
294 $this->assertFieldChecked('edit-language-interface-enabled-language-user');
295 $this->assertFieldChecked('edit-language-interface-enabled-language-browser');
297 // Make sure strings are still translated.
298 $this->drupalGet('admin/structure/views/view/content/translate/es/edit');
299 $this->assertText('Contenido');
300 $this->drupalPostForm('admin/config/regional/translate', ['string' => 'Full comment'], 'Filter');
301 $this->assertText('Comentario completo');
303 // Make sure our custom action is still there.
304 $this->drupalGet('admin/config/system/actions');
305 $this->assertText('Test action');
306 $this->drupalGet('admin/config/system/actions/configure/test_action');
307 $this->assertText('test_action');
308 $this->assertRaw('drupal.org');
310 // Make sure our ban still exists.
311 $this->drupalGet('admin/config/people/ban');
312 $this->assertText('8.8.8.8');
314 // Make sure our vocabulary exists.
315 $this->drupalGet('admin/structure/taxonomy/manage/test_vocabulary/overview');
317 // Make sure our terms exist.
318 $this->assertText('Test root term');
319 $this->assertText('Test child term');
320 $this->drupalGet('taxonomy/term/3');
321 $this->assertResponse('200');
323 // Make sure the terms are still translated.
324 $this->drupalGet('taxonomy/term/2/translations');
325 $this->assertLink('Test root term - Spanish');
327 // Make sure our contact form exists.
328 $this->drupalGet('admin/structure/contact');
329 $this->assertText('Test contact form');
330 $this->drupalGet('admin/structure/contact/manage/test_contact_form');
331 $this->assertText('test@example.com');
332 $this->assertText('Hello');
333 $this->drupalGet('admin/structure/contact/manage/test_contact_form/translate/es/edit');
334 $this->assertText('Hola');
335 $this->assertRaw('Test contact form Spanish');
337 // Make sure our modules are still enabled.
338 $expected_enabled_modules = [
351 'config_translation',
353 'content_translation',
401 foreach ($expected_enabled_modules as $module) {
402 $this->assertTrue($this->container->get('module_handler')->moduleExists($module), 'The "' . $module . '" module is still enabled.');
405 // Make sure our themes are still enabled.
406 $expected_enabled_themes = [
412 foreach ($expected_enabled_themes as $theme) {
413 $this->assertTrue($this->container->get('theme_handler')->themeExists($theme), 'The "' . $theme . '" is still enabled.');
416 // Ensure that the Book module's node type does not have duplicated enforced
418 // @see system_post_update_fix_enforced_dependencies()
419 $book_node_type = NodeType::load('book');
420 $this->assertEqual(['enforced' => ['module' => ['book']]], $book_node_type->get('dependencies'));
426 protected function replaceUser1() {
427 // Do not replace the user from our dump.