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.
15 class UpdatePathRC1TestBaseFilledTest extends UpdatePathRC1TestBaseTest {
20 protected function setDatabaseDumpFiles() {
21 parent::setDatabaseDumpFiles();
22 $this->databaseDumpFiles[0] = __DIR__ . '/../../../../tests/fixtures/update/drupal-8-rc1.filled.standard.php.gz';
26 * Tests that the content and configuration were properly updated.
28 public function testUpdatedSite() {
31 $spanish = \Drupal::languageManager()->getLanguage('es');
33 $expected_node_data = [
34 [1, 'article', 'en', 'Test Article - New title'],
35 [2, 'book', 'en', 'Book page'],
36 [3, 'forum', 'en', 'Forum topic'],
37 [4, 'page', 'en', 'Test page'],
38 [8, 'test_content_type', 'en', 'Test title'],
40 foreach ($expected_node_data as $node_data) {
42 $type = $node_data[1];
43 $langcode = $node_data[2];
44 $title = $node_data[3];
46 // Make sure our English nodes still exist.
47 $node = Node::load($id);
48 $this->assertEqual($node->language()->getId(), $langcode);
49 $this->assertEqual($node->getType(), $type);
50 $this->assertEqual($node->getTitle(), $title);
51 // Assert that nodes are all published.
52 $this->assertTrue($node->isPublished());
53 $this->drupalGet('node/' . $id);
54 $this->assertText($title);
57 // Make sure the translated node still exists.
58 $translation = Node::load(8)->getTranslation('es');
59 $this->assertEqual('Test title Spanish', $translation->getTitle());
61 // Make sure our alias still works.
62 $this->drupalGet('test-article');
63 $this->assertText('Test Article - New title');
64 $this->assertText('Body');
65 $this->assertText('Tags');
67 // Make sure a translated page exists.
68 $this->drupalGet('node/8', ['language' => $spanish]);
69 // Check for text of two comments.
70 $this->assertText('Hola');
71 $this->assertText('Hello');
72 // The user entity reference field is access restricted.
73 $this->assertNoText('Test 12');
74 // Make sure all other field labels are there.
75 for ($i = 1; $i <= 23; $i++) {
77 $this->assertText('Test ' . $i);
81 // Make sure the translated slogan appears.
82 $this->assertText('drupal Spanish');
84 // Make sure the custom block appears.
85 $this->drupalGet('<front>');
87 $this->assertText('Another block');
89 $this->assertText('Hello');
92 $account = User::load(1);
93 $account->passRaw = 'drupal';
94 $this->drupalLogin($account);
96 // Make sure we can see the access-restricted entity reference field
97 // now that we're logged in.
98 $this->drupalGet('node/8', ['language' => $spanish]);
99 $this->assertText('Test 12');
100 $this->assertLink('drupal');
102 // Make sure the content for node 8 is still in the edit form.
103 $this->drupalGet('node/8/edit');
104 $this->assertText('Test title');
105 $this->assertText('Test body');
106 $this->assertFieldChecked('edit-field-test-1-value');
107 $this->assertRaw('2015-08-16');
108 $this->assertRaw('test@example.com');
109 $this->assertRaw('drupal.org');
110 $this->assertText('0.1');
111 $this->assertText('0.2');
112 $this->assertRaw('+31612345678');
113 $this->assertRaw('+31612345679');
114 $this->assertText('Test Article - New title');
115 $this->assertText('test.txt');
116 $this->assertText('druplicon.small');
117 $this->assertRaw('General discussion');
118 $this->assertText('Test Article - New title');
119 $this->assertText('Test 1');
120 $this->assertRaw('0.01');
121 $this->drupalPostForm('node/8/edit', [], 'Save (this translation)');
122 $this->assertResponse(200);
123 $this->drupalGet('node/8/edit', ['language' => $spanish]);
124 $this->assertText('Test title Spanish');
125 $this->assertText('Test body Spanish');
127 // Make sure the user page is correct.
128 $this->drupalGet('user/3');
129 $this->assertText('usuario_test');
130 $this->assertRaw('druplicon.small');
131 $this->assertText('Test file field');
132 $this->assertLink('test.txt');
134 // Make sure the user is translated.
135 $this->drupalGet('user/3/translations');
136 $this->assertNoText('Not translated');
138 // Make sure the custom field on the user is still there.
139 $this->drupalGet('admin/config/people/accounts/fields');
140 $this->assertText('Test file field');
142 // Make sure the test view still exists.
143 $this->drupalGet('admin/structure/views/view/test_view');
144 $this->assertText('Test view');
146 // Make sure the book node exists.
147 $this->drupalGet('admin/structure/book');
148 $this->clickLink('Test Article - New title');
149 $this->assertText('Body');
150 $this->assertText('Tags');
151 $this->assertRaw('Text format');
153 // Make sure that users still exist.
154 $this->drupalGet('admin/people');
155 $this->assertText('usuario_test');
156 $this->assertText('drupal');
157 $this->drupalGet('user/1/edit');
158 $this->assertRaw('drupal@example.com');
160 // Make sure the content view works.
161 $this->drupalGet('admin/content');
162 $this->assertText('Test title');
164 // Make sure our custom blocks show up.
165 $this->drupalGet('admin/structure/block');
166 $this->assertText('Another block');
167 $this->assertText('Test block');
168 $this->drupalGet('admin/structure/block/block-content');
169 $this->assertText('Another block');
170 $this->assertText('Test block');
172 // Make sure our custom visibility conditions are correct.
173 $this->drupalGet('admin/structure/block/manage/testblock');
174 $this->assertNoFieldChecked('edit-visibility-language-langcodes-es');
175 $this->assertFieldChecked('edit-visibility-language-langcodes-en');
176 $this->assertNoFieldChecked('edit-visibility-node-type-bundles-book');
177 $this->assertFieldChecked('edit-visibility-node-type-bundles-test-content-type');
179 // Make sure our block is still translated.
180 $this->drupalGet('admin/structure/block/manage/testblock/translate/es/edit');
181 $this->assertRaw('Test block spanish');
183 // Make sure our custom text format exists.
184 $this->drupalGet('admin/config/content/formats');
185 $this->assertText('Test text format');
186 $this->drupalGet('admin/config/content/formats/manage/test_text_format');
187 $this->assertResponse('200');
189 // Make sure our feed still exists.
190 $this->drupalGet('admin/config/services/aggregator');
191 $this->assertText('Test feed');
192 $this->drupalGet('admin/config/services/aggregator/fields');
193 $this->assertText('field_test');
195 // Make sure our view appears in the overview.
196 $this->drupalGet('admin/structure/views');
197 $this->assertText('test_view');
198 $this->assertText('Test view');
200 // Make sure our custom forum exists.
201 $this->drupalGet('admin/structure/forum');
202 $this->assertText('Test forum');
204 // Make sure our custom menu exists.
205 $this->drupalGet('admin/structure/menu');
206 $this->assertText('Test menu');
208 // Make sure our custom menu exists.
209 $this->drupalGet('admin/structure/menu/manage/test-menu');
210 $this->clickLink('Admin');
211 // Make sure the translation for the menu is still correct.
212 $this->drupalGet('admin/structure/menu/manage/test-menu/translate/es/edit');
213 $this->assertRaw('Menu test');
214 // Make sure our custom menu link exists.
215 $this->drupalGet('admin/structure/menu/item/1/edit');
216 $this->assertFieldChecked('edit-enabled-value');
218 // Make sure our comment type exists.
219 $this->drupalGet('admin/structure/comment');
220 $this->assertText('Test comment type');
221 $this->drupalGet('admin/structure/comment/manage/test_comment_type/fields');
222 $this->assertText('comment_body');
224 // Make sure our contact form exists.
225 $this->drupalGet('admin/structure/contact');
226 $this->assertText('Test contact form');
227 $this->drupalGet('admin/structure/types');
228 $this->assertText('Test content type description');
229 $this->drupalGet('admin/structure/types/manage/test_content_type/fields');
231 // Make sure fields are the right type.
232 $this->assertLink('Text (formatted, long, with summary)');
233 $this->assertLink('Boolean');
234 $this->assertLink('Comments');
235 $this->assertLink('Date');
236 $this->assertLink('Email');
237 $this->assertLink('Link');
238 $this->assertLink('List (float)');
239 $this->assertLink('Telephone number');
240 $this->assertLink('Entity reference');
241 $this->assertLink('File');
242 $this->assertLink('Image');
243 $this->assertLink('Text (plain, long)');
244 $this->assertLink('List (text)');
245 $this->assertLink('Text (formatted, long)');
246 $this->assertLink('Text (plain)');
247 $this->assertLink('List (integer)');
248 $this->assertLink('Number (integer)');
249 $this->assertLink('Number (float)');
251 // Make sure our form mode exists.
252 $this->drupalGet('admin/structure/display-modes/form');
253 $this->assertText('New form mode');
255 // Make sure our view mode exists.
256 $this->drupalGet('admin/structure/display-modes/view');
257 $this->assertText('New view mode');
258 $this->drupalGet('admin/structure/display-modes/view/manage/node.new_view_mode');
259 $this->assertResponse(200);
261 // Make sure our other language is still there.
262 $this->drupalGet('admin/config/regional/language');
263 $this->assertText('Spanish');
265 // Make sure our custom date format exists.
266 $this->drupalGet('admin/config/regional/date-time');
267 $this->assertText('Test date format');
268 $this->drupalGet('admin/config/regional/date-time/formats/manage/test_date_format');
269 $this->assertOptionSelected('edit-langcode', 'es');
271 // Make sure our custom image style exists.
272 $this->drupalGet('admin/config/media/image-styles/manage/test_image_style');
273 $this->assertText('Test image style');
274 $this->assertText('Desaturate');
275 $this->assertText('Convert PNG');
277 // Make sure our custom responsive image style exists.
278 $this->drupalGet('admin/config/media/responsive-image-style/test');
279 $this->assertResponse(200);
280 $this->assertText('Test');
282 // Make sure our custom shortcut exists.
283 $this->drupalGet('admin/config/user-interface/shortcut');
284 $this->assertText('Test shortcut');
285 $this->drupalGet('admin/config/user-interface/shortcut/manage/test/customize');
286 $this->assertText('All content');
288 // Make sure our language detection settings are still correct.
289 $this->drupalGet('admin/config/regional/language/detection');
290 $this->assertFieldChecked('edit-language-interface-enabled-language-user-admin');
291 $this->assertFieldChecked('edit-language-interface-enabled-language-url');
292 $this->assertFieldChecked('edit-language-interface-enabled-language-session');
293 $this->assertFieldChecked('edit-language-interface-enabled-language-user');
294 $this->assertFieldChecked('edit-language-interface-enabled-language-browser');
296 // Make sure strings are still translated.
297 $this->drupalGet('admin/structure/views/view/content/translate/es/edit');
298 $this->assertText('Contenido');
299 $this->drupalPostForm('admin/config/regional/translate', ['string' => 'Full comment'], 'Filter');
300 $this->assertText('Comentario completo');
302 // Make sure our custom action is still there.
303 $this->drupalGet('admin/config/system/actions');
304 $this->assertText('Test action');
305 $this->drupalGet('admin/config/system/actions/configure/test_action');
306 $this->assertText('test_action');
307 $this->assertRaw('drupal.org');
309 // Make sure our ban still exists.
310 $this->drupalGet('admin/config/people/ban');
311 $this->assertText('8.8.8.8');
313 // Make sure our vocabulary exists.
314 $this->drupalGet('admin/structure/taxonomy/manage/test_vocabulary/overview');
316 // Make sure our terms exist.
317 $this->assertText('Test root term');
318 $this->assertText('Test child term');
319 $this->drupalGet('taxonomy/term/3');
320 $this->assertResponse('200');
322 // Make sure the terms are still translated.
323 $this->drupalGet('taxonomy/term/2/translations');
324 $this->assertLink('Test root term - Spanish');
326 // Make sure our contact form exists.
327 $this->drupalGet('admin/structure/contact');
328 $this->assertText('Test contact form');
329 $this->drupalGet('admin/structure/contact/manage/test_contact_form');
330 $this->assertText('test@example.com');
331 $this->assertText('Hello');
332 $this->drupalGet('admin/structure/contact/manage/test_contact_form/translate/es/edit');
333 $this->assertText('Hola');
334 $this->assertRaw('Test contact form Spanish');
336 // Make sure our modules are still enabled.
337 $expected_enabled_modules = [
350 'config_translation',
352 'content_translation',
400 foreach ($expected_enabled_modules as $module) {
401 $this->assertTrue($this->container->get('module_handler')->moduleExists($module), 'The "' . $module . '" module is still enabled.');
404 // Make sure our themes are still enabled.
405 $expected_enabled_themes = [
411 foreach ($expected_enabled_themes as $theme) {
412 $this->assertTrue($this->container->get('theme_handler')->themeExists($theme), 'The "' . $theme . '" is still enabled.');
415 // Ensure that the Book module's node type does not have duplicated enforced
417 // @see system_post_update_fix_enforced_dependencies()
418 $book_node_type = NodeType::load('book');
419 $this->assertEqual(['enforced' => ['module' => ['book']]], $book_node_type->get('dependencies'));
425 protected function replaceUser1() {
426 // Do not replace the user from our dump.