Mercurial > hg > cmmr2012-drupal-site
diff core/modules/content_translation/src/Tests/ContentTranslationUITestBase.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 |
line wrap: on
line diff
--- a/core/modules/content_translation/src/Tests/ContentTranslationUITestBase.php Thu Feb 28 13:11:55 2019 +0000 +++ b/core/modules/content_translation/src/Tests/ContentTranslationUITestBase.php Thu May 09 15:34:47 2019 +0100 @@ -2,6 +2,8 @@ namespace Drupal\content_translation\Tests; +@trigger_error(__NAMESPACE__ . '\ContentTranslationUITestBase is deprecated for removal before Drupal 9.0.0. Use Drupal\Tests\content_translation\Functional\ContentTranslationUITestBase instead. See https://www.drupal.org/node/2999939', E_USER_DEPRECATED); + use Drupal\Core\Cache\Cache; use Drupal\Core\Entity\EntityChangedInterface; use Drupal\Core\Entity\EntityInterface; @@ -17,6 +19,8 @@ * * @deprecated Scheduled for removal in Drupal 9.0.0. * Use \Drupal\Tests\content_translation\Functional\ContentTranslationUITestBase instead. + * + * @see https://www.drupal.org/node/2999939 */ abstract class ContentTranslationUITestBase extends ContentTranslationTestBase { @@ -85,14 +89,14 @@ $storage->resetCache([$this->entityId]); $entity = $storage->load($this->entityId); $this->assertTrue($entity, 'Entity found in the database.'); - $this->drupalGet($entity->urlInfo()); + $this->drupalGet($entity->toUrl()); $this->assertResponse(200, 'Entity URL is valid.'); // Ensure that the content language cache context is not yet added to the // page. $this->assertCacheContexts($this->defaultCacheContexts); - $this->drupalGet($entity->urlInfo('drupal:content-translation-overview')); + $this->drupalGet($entity->toUrl('drupal:content-translation-overview')); $this->assertNoText('Source language', 'Source language column correctly hidden.'); $translation = $this->getTranslation($entity, $default_langcode); @@ -128,7 +132,7 @@ ->getStorage($this->entityTypeId); $storage->resetCache([$this->entityId]); $entity = $storage->load($this->entityId); - $this->drupalGet($entity->urlInfo()); + $this->drupalGet($entity->toUrl()); $this->assertCacheContexts(Cache::mergeContexts(['languages:language_content'], $this->defaultCacheContexts)); // Reset the cache of the entity, so that the new translation gets the @@ -164,7 +168,7 @@ } $storage->resetCache([$this->entityId]); $entity = $storage->load($this->entityId); - $this->drupalGet($entity->urlInfo('drupal:content-translation-overview')); + $this->drupalGet($entity->toUrl('drupal:content-translation-overview')); $this->assertNoText('Source language', 'Source language column correctly hidden.'); // Switch the source language. @@ -195,7 +199,7 @@ $this->drupalPostForm($add_url, $edit, $this->getFormSubmitActionForNewTranslation($entity, $langcode)); $storage->resetCache([$this->entityId]); $entity = $storage->load($this->entityId); - $this->drupalGet($entity->urlInfo('drupal:content-translation-overview')); + $this->drupalGet($entity->toUrl('drupal:content-translation-overview')); $this->assertText('Source language', 'Source language column correctly shown.'); // Check that the entered values have been correctly stored. @@ -218,17 +222,17 @@ ->getStorage($this->entityTypeId); $storage->resetCache([$this->entityId]); $entity = $storage->load($this->entityId); - $translate_url = $entity->urlInfo('drupal:content-translation-overview'); + $translate_url = $entity->toUrl('drupal:content-translation-overview'); $this->drupalGet($translate_url); $translate_url->setAbsolute(FALSE); foreach ($this->langcodes as $langcode) { if ($entity->hasTranslation($langcode)) { $language = new Language(['id' => $langcode]); - $view_url = $entity->url('canonical', ['language' => $language]); + $view_url = $entity->toUrl('canonical', ['language' => $language])->toString(); $elements = $this->xpath('//table//a[@href=:href]', [':href' => $view_url]); $this->assertEqual((string) $elements[0], $entity->getTranslation($langcode)->label(), format_string('Label correctly shown for %language translation.', ['%language' => $langcode])); - $edit_path = $entity->url('edit-form', ['language' => $language]); + $edit_path = $entity->toUrl('edit-form', ['language' => $language])->toString(); $elements = $this->xpath('//table//ul[@class="dropbutton"]/li/a[@href=:href]', [':href' => $edit_path]); $this->assertEqual((string) $elements[0], t('Edit'), format_string('Edit link correct for %language translation.', ['%language' => $langcode])); } @@ -248,7 +252,7 @@ // Mark translations as outdated. $edit = ['content_translation[retranslate]' => TRUE]; - $edit_path = $entity->urlInfo('edit-form', ['language' => $languages[$langcode]]); + $edit_path = $entity->toUrl('edit-form', ['language' => $languages[$langcode]]); $this->drupalPostForm($edit_path, $edit, $this->getFormSubmitAction($entity, $langcode)); $storage->resetCache([$this->entityId]); $entity = $storage->load($this->entityId); @@ -256,7 +260,7 @@ // Check that every translation has the correct "outdated" status, and that // the Translation fieldset is open if the translation is "outdated". foreach ($this->langcodes as $added_langcode) { - $url = $entity->urlInfo('edit-form', ['language' => ConfigurableLanguage::load($added_langcode)]); + $url = $entity->toUrl('edit-form', ['language' => ConfigurableLanguage::load($added_langcode)]); $this->drupalGet($url); if ($added_langcode == $langcode) { $this->assertFieldByXPath('//input[@name="content_translation[retranslate]"]', FALSE, 'The retranslate flag is not checked by default.'); @@ -290,7 +294,7 @@ // Unpublish translations. foreach ($this->langcodes as $index => $langcode) { if ($index > 0) { - $url = $entity->urlInfo('edit-form', ['language' => ConfigurableLanguage::load($langcode)]); + $url = $entity->toUrl('edit-form', ['language' => ConfigurableLanguage::load($langcode)]); $edit = ['content_translation[status]' => FALSE]; $this->drupalPostForm($url, $edit, $this->getFormSubmitAction($entity, $langcode)); $storage = $this->container->get('entity_type.manager') @@ -302,7 +306,7 @@ } // Check that the last published translation cannot be unpublished. - $this->drupalGet($entity->urlInfo('edit-form')); + $this->drupalGet($entity->toUrl('edit-form')); $this->assertFieldByXPath('//input[@name="content_translation[status]" and @disabled="disabled"]', TRUE, 'The last translation is published and cannot be unpublished.'); } @@ -324,10 +328,10 @@ 'created' => REQUEST_TIME - mt_rand(0, 1000), ]; $edit = [ - 'content_translation[uid]' => $user->getUsername(), - 'content_translation[created]' => format_date($values[$langcode]['created'], 'custom', 'Y-m-d H:i:s O'), + 'content_translation[uid]' => $user->getAccountName(), + 'content_translation[created]' => $this->container->get('date.formatter')->format($values[$langcode]['created'], 'custom', 'Y-m-d H:i:s O'), ]; - $url = $entity->urlInfo('edit-form', ['language' => ConfigurableLanguage::load($langcode)]); + $url = $entity->toUrl('edit-form', ['language' => ConfigurableLanguage::load($langcode)]); $this->drupalPostForm($url, $edit, $this->getFormSubmitAction($entity, $langcode)); } @@ -348,7 +352,7 @@ 'content_translation[uid]' => $this->randomMachineName(12), 'content_translation[created]' => '19/11/1978', ]; - $this->drupalPostForm($entity->urlInfo('edit-form'), $edit, $this->getFormSubmitAction($entity, $langcode)); + $this->drupalPostForm($entity->toUrl('edit-form'), $edit, $this->getFormSubmitAction($entity, $langcode)); $this->assertTrue($this->xpath('//div[contains(@class, "error")]//ul'), 'Invalid values generate a list of form errors.'); $metadata = $this->manager->getTranslationMetadata($entity->getTranslation($langcode)); $this->assertEqual($metadata->getAuthor()->id(), $values[$langcode]['uid'], 'Translation author correctly kept.'); @@ -367,7 +371,7 @@ $storage->resetCache([$this->entityId]); $entity = $storage->load($this->entityId); $language = ConfigurableLanguage::load($langcode); - $url = $entity->urlInfo('edit-form', ['language' => $language]); + $url = $entity->toUrl('edit-form', ['language' => $language]); $this->drupalPostForm($url, [], t('Delete translation')); $this->drupalPostForm(NULL, [], t('Delete @language translation', ['@language' => $language->getName()])); $storage->resetCache([$this->entityId]); @@ -511,7 +515,7 @@ // We only want to test the title for non-english translations. if ($langcode != 'en') { $options = ['language' => $languages[$langcode]]; - $url = $entity->urlInfo('edit-form', $options); + $url = $entity->toUrl('edit-form', $options); $this->drupalGet($url); $this->assertRaw($entity->getTranslation($langcode)->label()); @@ -556,7 +560,7 @@ $edit = [ $this->fieldName . '[0][value]' => $this->randomString(), ]; - $edit_path = $entity->urlInfo('edit-form', ['language' => $language]); + $edit_path = $entity->toUrl('edit-form', ['language' => $language]); $this->drupalPostForm($edit_path, $edit, $this->getFormSubmitAction($entity, $langcode)); $storage = $this->container->get('entity_type.manager') @@ -616,7 +620,7 @@ // Save the entity on the regular edit form. $language = $entity->language(); - $edit_path = $entity->urlInfo('edit-form', ['language' => $language]); + $edit_path = $entity->toUrl('edit-form', ['language' => $language]); $this->drupalPostForm($edit_path, [], $this->getFormSubmitAction($entity, $language->getId())); $storage->resetCache([$this->entityId]);