comparison core/modules/node/tests/src/Functional/NodeTranslationUITest.php @ 5:12f9dff5fda9 tip

Update to Drupal core 8.7.1
author Chris Cannam
date Thu, 09 May 2019 15:34:47 +0100
parents a9cd425dd02b
children
comparison
equal deleted inserted replaced
4:a9cd425dd02b 5:12f9dff5fda9
24 'theme', 24 'theme',
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 'url.site',
29 'user.roles', 30 'user.roles',
30 'url.path.is_front', 31 'url.path.is_front',
31 // These two cache contexts are added by BigPipe. 32 // These two cache contexts are added by BigPipe.
32 'cookies:big_pipe_nojs', 33 'cookies:big_pipe_nojs',
33 'session.exists', 34 'session.exists',
159 foreach ($statuses as $index => $value) { 160 foreach ($statuses as $index => $value) {
160 // (Un)publish the node translations and check that the translation 161 // (Un)publish the node translations and check that the translation
161 // statuses are (un)published accordingly. 162 // statuses are (un)published accordingly.
162 foreach ($this->langcodes as $langcode) { 163 foreach ($this->langcodes as $langcode) {
163 $options = ['language' => $languages[$langcode]]; 164 $options = ['language' => $languages[$langcode]];
164 $url = $entity->urlInfo('edit-form', $options); 165 $url = $entity->toUrl('edit-form', $options);
165 $this->drupalPostForm($url, ['status[value]' => $value], t('Save') . $this->getFormSubmitSuffix($entity, $langcode), $options); 166 $this->drupalPostForm($url, ['status[value]' => $value], t('Save') . $this->getFormSubmitSuffix($entity, $langcode), $options);
166 } 167 }
167 $storage->resetCache([$this->entityId]); 168 $storage->resetCache([$this->entityId]);
168 $entity = $storage->load($this->entityId); 169 $entity = $storage->load($this->entityId);
169 foreach ($this->langcodes as $langcode) { 170 foreach ($this->langcodes as $langcode) {
194 'uid' => $user->id(), 195 'uid' => $user->id(),
195 'created' => REQUEST_TIME - mt_rand(0, 1000), 196 'created' => REQUEST_TIME - mt_rand(0, 1000),
196 'sticky' => (bool) mt_rand(0, 1), 197 'sticky' => (bool) mt_rand(0, 1),
197 'promote' => (bool) mt_rand(0, 1), 198 'promote' => (bool) mt_rand(0, 1),
198 ]; 199 ];
200 /** @var \Drupal\Core\Datetime\DateFormatterInterface $date_formatter */
201 $date_formatter = $this->container->get('date.formatter');
199 $edit = [ 202 $edit = [
200 'uid[0][target_id]' => $user->getUsername(), 203 'uid[0][target_id]' => $user->getAccountName(),
201 'created[0][value][date]' => format_date($values[$langcode]['created'], 'custom', 'Y-m-d'), 204 'created[0][value][date]' => $date_formatter->format($values[$langcode]['created'], 'custom', 'Y-m-d'),
202 'created[0][value][time]' => format_date($values[$langcode]['created'], 'custom', 'H:i:s'), 205 'created[0][value][time]' => $date_formatter->format($values[$langcode]['created'], 'custom', 'H:i:s'),
203 'sticky[value]' => $values[$langcode]['sticky'], 206 'sticky[value]' => $values[$langcode]['sticky'],
204 'promote[value]' => $values[$langcode]['promote'], 207 'promote[value]' => $values[$langcode]['promote'],
205 ]; 208 ];
206 $options = ['language' => $languages[$langcode]]; 209 $options = ['language' => $languages[$langcode]];
207 $url = $entity->urlInfo('edit-form', $options); 210 $url = $entity->toUrl('edit-form', $options);
208 $this->drupalPostForm($url, $edit, $this->getFormSubmitAction($entity, $langcode), $options); 211 $this->drupalPostForm($url, $edit, $this->getFormSubmitAction($entity, $langcode), $options);
209 } 212 }
210 213
211 $storage->resetCache([$this->entityId]); 214 $storage->resetCache([$this->entityId]);
212 $entity = $storage->load($this->entityId); 215 $entity = $storage->load($this->entityId);
351 354
352 // Test that the node page displays the correct translations. 355 // Test that the node page displays the correct translations.
353 $this->doTestTranslations('node/' . $node->id(), $values); 356 $this->doTestTranslations('node/' . $node->id(), $values);
354 357
355 // Test that the node page has the correct alternate hreflang links. 358 // Test that the node page has the correct alternate hreflang links.
356 $this->doTestAlternateHreflangLinks($node->urlInfo()); 359 $this->doTestAlternateHreflangLinks($node->toUrl());
357 } 360 }
358 361
359 /** 362 /**
360 * Tests that the given path displays the correct translation values. 363 * Tests that the given path displays the correct translation values.
361 * 364 *
438 441
439 foreach ($this->langcodes as $langcode) { 442 foreach ($this->langcodes as $langcode) {
440 // We only want to test the title for non-english translations. 443 // We only want to test the title for non-english translations.
441 if ($langcode != 'en') { 444 if ($langcode != 'en') {
442 $options = ['language' => $languages[$langcode]]; 445 $options = ['language' => $languages[$langcode]];
443 $url = $entity->urlInfo('edit-form', $options); 446 $url = $entity->toUrl('edit-form', $options);
444 $this->drupalGet($url); 447 $this->drupalGet($url);
445 448
446 $title = t('<em>Edit @type</em> @title [%language translation]', [ 449 $title = t('<em>Edit @type</em> @title [%language translation]', [
447 '@type' => $type_name, 450 '@type' => $type_name,
448 '@title' => $entity->getTranslation($langcode)->label(), 451 '@title' => $entity->getTranslation($langcode)->label(),