You are here

protected function ConfigTranslationUiTest::setUp in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 core/modules/config_translation/src/Tests/ConfigTranslationUiTest.php \Drupal\config_translation\Tests\ConfigTranslationUiTest::setUp()

Sets up a Drupal site for running functional and integration tests.

Installs Drupal with the installation profile specified in \Drupal\simpletest\WebTestBase::$profile into the prefixed database.

Afterwards, installs any additional modules specified in the static \Drupal\simpletest\WebTestBase::$modules property of each class in the class hierarchy.

After installation all caches are flushed and several configuration values are reset to the values of the parent site executing the test, since the default values may be incompatible with the environment in which tests are being executed.

Overrides WebTestBase::setUp

File

core/modules/config_translation/src/Tests/ConfigTranslationUiTest.php, line 77
Contains \Drupal\config_translation\Tests\ConfigTranslationUiTest.

Class

ConfigTranslationUiTest
Translate settings and entities to various languages.

Namespace

Drupal\config_translation\Tests

Code

protected function setUp() {
  parent::setUp();
  $translator_permissions = [
    'translate configuration',
  ];

  /** @var \Drupal\filter\FilterFormatInterface $filter_test_format */
  $filter_test_format = entity_load('filter_format', 'filter_test');

  /** @var \Drupal\filter\FilterFormatInterface $filtered_html_format */
  $filtered_html_format = entity_load('filter_format', 'filtered_html');

  /** @var \Drupal\filter\FilterFormatInterface $full_html_format */
  $full_html_format = entity_load('filter_format', 'full_html');
  $admin_permissions = array_merge($translator_permissions, [
    'administer languages',
    'administer site configuration',
    'link to any page',
    'administer contact forms',
    'administer filters',
    $filtered_html_format
      ->getPermissionName(),
    $full_html_format
      ->getPermissionName(),
    $filter_test_format
      ->getPermissionName(),
    'access site-wide contact form',
    'access contextual links',
    'administer views',
    'administer account settings',
    'administer themes',
    'bypass node access',
    'administer content types',
    'translate interface',
  ]);

  // Create and login user.
  $this->translatorUser = $this
    ->drupalCreateUser($translator_permissions);
  $this->adminUser = $this
    ->drupalCreateUser($admin_permissions);

  // Add languages.
  foreach ($this->langcodes as $langcode) {
    ConfigurableLanguage::createFromLangcode($langcode)
      ->save();
  }
  $this->localeStorage = $this->container
    ->get('locale.storage');
  $this
    ->drupalPlaceBlock('local_tasks_block');
  $this
    ->drupalPlaceBlock('page_title_block');
}