Updated to Drupal 8.5. Core Media not yet in use.
[yaffs-website] / web / core / modules / content_translation / tests / src / Functional / ContentTranslationTestBase.php
index ec7f87dd1bc32138306699b105b432fa58ac28c2..82715c28c293c003856607bdece19764dc9d478e 100644 (file)
@@ -2,6 +2,7 @@
 
 namespace Drupal\Tests\content_translation\Functional;
 
+use Drupal\Core\Entity\ContentEntityInterface;
 use Drupal\Core\Entity\Sql\SqlContentEntityStorage;
 use Drupal\field\Entity\FieldConfig;
 use Drupal\language\Entity\ConfigurableLanguage;
@@ -138,7 +139,7 @@ abstract class ContentTranslationTestBase extends BrowserTestBase {
    * Returns an array of permissions needed for the administrator.
    */
   protected function getAdministratorPermissions() {
-    return array_merge($this->getEditorPermissions(), $this->getTranslatorPermissions(), ['administer content translation']);
+    return array_merge($this->getEditorPermissions(), $this->getTranslatorPermissions(), ['administer languages', 'administer content translation']);
   }
 
   /**
@@ -236,4 +237,24 @@ abstract class ContentTranslationTestBase extends BrowserTestBase {
     return $entity->id();
   }
 
+  /**
+   * Returns the edit URL for the specified entity.
+   *
+   * @param \Drupal\Core\Entity\ContentEntityInterface $entity
+   *   The entity being edited.
+   *
+   * @return \Drupal\Core\Url
+   *   The edit URL.
+   */
+  protected function getEditUrl(ContentEntityInterface $entity) {
+    if ($entity->access('update', $this->loggedInUser)) {
+      $url = $entity->toUrl('edit-form');
+    }
+    else {
+      $url = $entity->toUrl('drupal:content-translation-edit');
+      $url->setRouteParameter('language', $entity->language()->getId());
+    }
+    return $url;
+  }
+
 }