l10n_server-2.x-dev/l10n_community/tests/src/Functional/L10nServerTest.php

l10n_community/tests/src/Functional/L10nServerTest.php
<?php

namespace Drupal\Tests\l10n_community\Functional;

use Drupal\Tests\BrowserTestBase;
use Drupal\user\Entity\User;

/**
 * Test description.
 *
 * @group l10n_community
 */
class L10nServerTest extends BrowserTestBase {

  /**
   * Version base.
   *
   * @var string
   */
  private string $versionBase = '3.5';

  /**
   * Version JS.
   *
   * @var string
   */
  private string $versionJs = '5.7';

  /**
   * {@inheritdoc}
   */
  protected $defaultTheme = 'stable9';

  /**
   * {@inheritdoc}
   */
  protected static $modules = [
    'file', 'group', 'gnode', 'locale', 'language', 'l10n_pconfig', 'l10n_server',
    'l10n_drupal_rest', 'l10n_community', 'l10n_pconfig', 'potx', 'views',
  ];

  /**
   * Anonymous user.
   *
   * @var \Drupal\user\Entity\User
   */
  private User $userAnonymous;

  /**
   * Authenticated user.
   *
   * @var \Drupal\user\Entity\User
   */
  private User $userAuthenticated;

  /**
   * First member user.
   *
   * @var \Drupal\user\Entity\User
   */
  private User $userMember1;

  /**
   * Second member user.
   *
   * @var \Drupal\user\Entity\User
   */
  private User $userMember2;

  /**
   * Moderator user.
   *
   * @var \Drupal\user\Entity\User
   */
  private User $userModerator;

  /**
   * Admin user.
   *
   * @var \Drupal\user\Entity\User
   */
  private User $userAdmin;

  /**
   * Team user.
   *
   * @var \Drupal\user\Entity\User
   */
  private User $userTeam;

  /**
   * {@inheritdoc}
   */
  protected function setUp(): void {
    parent::setUp();

    // Prepare users on different permission levels.
    $this->userAnonymous = $this->drupalCreateUser();
    $this->userAuthenticated = $this->drupalCreateUser([
      'access localization community', 'browse translations',
      'view l10n server project', 'view l10n server release',
    ]);
    $this->userMember1 = $this->drupalCreateUser([
      'access localization community', 'browse translations',
      'submit suggestions', 'import gettext files',
    ]);
    $this->userMember2 = $this->drupalCreateUser([
      'access localization community', 'browse translations',
      'submit suggestions', 'import gettext files',
    ]);
    $this->userModerator = $this->drupalCreateUser([
      'access localization community', 'browse translations',
      'moderate own suggestions', 'moderate suggestions from others',
      'import gettext files', 'submit suggestions',
    ]);
    $this->userAdmin = $this->drupalCreateUser([
      'administer languages', 'administer localization server',
      'import gettext files',
    ]);
    $this->userTeam = $this->drupalCreateUser();

    // Set up temporary directory for our work. Because this is inside the
    // simpletest controlled file path, it will be cleaned up later.
    $this->temp_path = \Drupal::service('file_system')
      ->realpath('temporary://l10n_community_test');
    if (!is_dir($this->temp_path)) {
      mkdir($this->temp_path);
    }
    else {
      \Drupal::service('environment_cleaner')->cleanTemporaryDirectories();
    }
    $this->full_temp_path = $this->temp_path;

    // Actually enable the Drupal connector.
    $this->config('l10n_server.settings')->set('enabled_connectors', [
      'drupal_rest:restapi',
    ]);
    $config = [
      'scan_limit' => 1,
      'cron_scanning_enabled' => 0,
      'max_filesize' => 52428800,
      'refresh_url' => 'https://www.drupal.org/files/releases.tsv',
    ];
    foreach ($config as $name => $value) {
      $this->config('l10n_server.settings')
        ->set('connectors.drupal_rest:restapi.source.restapi.' . $name, $value);
    }

    $this->project_names = [];

    // Store empty error message for reuse in multiple cases.
    $this->empty_error = t('Empty string attempted to be localized. Please do not leave test code for localization in your source.');
  }

  /**
   * Test stub.
   */
  public function testStub() {
    $this->assertTrue(TRUE);
  }

}

Главная | Обратная связь

drupal hosting | друпал хостинг | it patrol .inc