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