MediaTranslationUITest.php 1.9 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96
<?php

namespace Drupal\Tests\media\Functional;

use Drupal\Tests\content_translation\Functional\ContentTranslationUITestBase;
use Drupal\Tests\media\Traits\MediaTypeCreationTrait;

/**
 * Tests the Media Translation UI.
 *
 * @group media
 */
class MediaTranslationUITest extends ContentTranslationUITestBase {

  use MediaTypeCreationTrait;

  /**
   * {inheritdoc}
   */
  protected $defaultCacheContexts = [
    'languages:language_interface',
    'theme',
    'timezone',
    'url.query_args:_wrapper_format',
    'user.permissions',
  ];

  /**
   * {inheritdoc}
   */
  public static $modules = [
    'language',
    'content_translation',
    'media',
    'media_test_source',
  ];

  /**
   * {@inheritdoc}
   */
  protected function setUp() {
    $this->entityTypeId = 'media';
    $this->bundle = 'test';
    parent::setUp();
  }

  /**
   * {@inheritdoc}
   */
  public function setupBundle() {
    $this->createMediaType('test', [
      'id' => $this->bundle,
      'queue_thumbnail_downloads' => FALSE,
    ]);
  }

  /**
   * {@inheritdoc}
   */
  protected function getTranslatorPermissions() {
    return array_merge(parent::getTranslatorPermissions(), [
      'administer media',
      'edit any test media',
    ]);
  }

  /**
   * {@inheritdoc}
   */
  protected function getEditorPermissions() {
    return ['administer media', 'create test media'];
  }

  /**
   * {@inheritdoc}
   */
  protected function getAdministratorPermissions() {
    return array_merge(parent::getAdministratorPermissions(), [
      'access administration pages',
      'administer media types',
      'access media overview',
      'administer languages',
    ]);
  }

  /**
   * {@inheritdoc}
   */
  protected function getNewEntityValues($langcode) {
    return [
      'name' => [['value' => $this->randomMachineName()]],
      'field_media_test' => [['value' => $this->randomMachineName()]],
    ] + parent::getNewEntityValues($langcode);
  }

}