Mercurial > hg > isophonics-drupal-site
comparison core/modules/node/tests/src/Functional/NodeTranslationUITest.php @ 17:129ea1e6d783
Update, including to Drupal core 8.6.10
author | Chris Cannam |
---|---|
date | Thu, 28 Feb 2019 13:21:36 +0000 |
parents | 1fec387a4317 |
children | af1871eacc83 |
comparison
equal
deleted
inserted
replaced
16:c2387f117808 | 17:129ea1e6d783 |
---|---|
25 'route', | 25 'route', |
26 'timezone', | 26 'timezone', |
27 'url.path.parent', | 27 'url.path.parent', |
28 'url.query_args:_wrapper_format', | 28 'url.query_args:_wrapper_format', |
29 'user.roles', | 29 'user.roles', |
30 'url.path.is_front', | |
30 // These two cache contexts are added by BigPipe. | 31 // These two cache contexts are added by BigPipe. |
31 'cookies:big_pipe_nojs', | 32 'cookies:big_pipe_nojs', |
32 'session.exists', | 33 'session.exists', |
33 ]; | 34 ]; |
34 | 35 |
97 | 98 |
98 $entity_type_id = $entity->getEntityTypeId(); | 99 $entity_type_id = $entity->getEntityTypeId(); |
99 $add_url = Url::fromRoute("entity.$entity_type_id.content_translation_add", [ | 100 $add_url = Url::fromRoute("entity.$entity_type_id.content_translation_add", [ |
100 $entity->getEntityTypeId() => $entity->id(), | 101 $entity->getEntityTypeId() => $entity->id(), |
101 'source' => $default_langcode, | 102 'source' => $default_langcode, |
102 'target' => $langcode | 103 'target' => $langcode, |
103 ], ['language' => $language]); | 104 ], ['language' => $language]); |
104 $edit = $this->getEditValues($values, $langcode); | 105 $edit = $this->getEditValues($values, $langcode); |
105 $edit['status[value]'] = FALSE; | 106 $edit['status[value]'] = FALSE; |
106 $this->drupalPostForm($add_url, $edit, t('Save (this translation)')); | 107 $this->drupalPostForm($add_url, $edit, t('Save (this translation)')); |
107 | 108 |
282 foreach (array_diff($this->langcodes, [$default_langcode]) as $langcode) { | 283 foreach (array_diff($this->langcodes, [$default_langcode]) as $langcode) { |
283 $values[$langcode] = $this->getNewEntityValues($langcode); | 284 $values[$langcode] = $this->getNewEntityValues($langcode); |
284 $translation = $node->addTranslation($langcode, $values[$langcode]); | 285 $translation = $node->addTranslation($langcode, $values[$langcode]); |
285 // Publish and promote the translation to frontpage. | 286 // Publish and promote the translation to frontpage. |
286 $translation->setPromoted(TRUE); | 287 $translation->setPromoted(TRUE); |
287 $translation->setPublished(TRUE); | 288 $translation->setPublished(); |
288 } | 289 } |
289 $node->save(); | 290 $node->save(); |
290 | 291 |
291 // Test that the frontpage view displays the correct translations. | 292 // Test that the frontpage view displays the correct translations. |
292 \Drupal::service('module_installer')->install(['views'], TRUE); | 293 \Drupal::service('module_installer')->install(['views'], TRUE); |
499 // Contents should be in French, of correct revision. | 500 // Contents should be in French, of correct revision. |
500 $this->assertText('First rev fr title'); | 501 $this->assertText('First rev fr title'); |
501 $this->assertNoText('First rev en title'); | 502 $this->assertNoText('First rev en title'); |
502 } | 503 } |
503 | 504 |
505 /** | |
506 * Test that title is not escaped (but XSS-filtered) for details form element. | |
507 */ | |
508 public function testDetailsTitleIsNotEscaped() { | |
509 $this->drupalLogin($this->administrator); | |
510 // Make the image field a multi-value field in order to display a | |
511 // details form element. | |
512 $edit = ['cardinality_number' => 2]; | |
513 $this->drupalPostForm('admin/structure/types/manage/article/fields/node.article.field_image/storage', $edit, t('Save field settings')); | |
514 | |
515 // Make the image field non-translatable. | |
516 $edit = ['settings[node][article][fields][field_image]' => FALSE]; | |
517 $this->drupalPostForm('admin/config/regional/content-language', $edit, t('Save configuration')); | |
518 | |
519 // Create a node. | |
520 $nid = $this->createEntity(['title' => 'Node with multi-value image field en title'], 'en'); | |
521 | |
522 // Add a French translation and assert the title markup is not escaped. | |
523 $this->drupalGet("node/$nid/translations/add/en/fr"); | |
524 $markup = 'Image <span class="translation-entity-all-languages">(all languages)</span>'; | |
525 $this->assertSession()->assertNoEscaped($markup); | |
526 $this->assertSession()->responseContains($markup); | |
527 } | |
528 | |
504 } | 529 } |