You are here

protected function LingotekNodeTabsThemeTest::setUp in Lingotek Translation 3.5.x

Same name and namespace in other branches
  1. 8.2 tests/src/Functional/LingotekNodeTabsThemeTest.php \Drupal\Tests\lingotek\Functional\LingotekNodeTabsThemeTest::setUp()
  2. 4.0.x tests/src/Functional/LingotekNodeTabsThemeTest.php \Drupal\Tests\lingotek\Functional\LingotekNodeTabsThemeTest::setUp()
  3. 3.0.x tests/src/Functional/LingotekNodeTabsThemeTest.php \Drupal\Tests\lingotek\Functional\LingotekNodeTabsThemeTest::setUp()
  4. 3.1.x tests/src/Functional/LingotekNodeTabsThemeTest.php \Drupal\Tests\lingotek\Functional\LingotekNodeTabsThemeTest::setUp()
  5. 3.2.x tests/src/Functional/LingotekNodeTabsThemeTest.php \Drupal\Tests\lingotek\Functional\LingotekNodeTabsThemeTest::setUp()
  6. 3.3.x tests/src/Functional/LingotekNodeTabsThemeTest.php \Drupal\Tests\lingotek\Functional\LingotekNodeTabsThemeTest::setUp()
  7. 3.4.x tests/src/Functional/LingotekNodeTabsThemeTest.php \Drupal\Tests\lingotek\Functional\LingotekNodeTabsThemeTest::setUp()
  8. 3.6.x tests/src/Functional/LingotekNodeTabsThemeTest.php \Drupal\Tests\lingotek\Functional\LingotekNodeTabsThemeTest::setUp()
  9. 3.7.x tests/src/Functional/LingotekNodeTabsThemeTest.php \Drupal\Tests\lingotek\Functional\LingotekNodeTabsThemeTest::setUp()
  10. 3.8.x tests/src/Functional/LingotekNodeTabsThemeTest.php \Drupal\Tests\lingotek\Functional\LingotekNodeTabsThemeTest::setUp()

Overrides LingotekTestBase::setUp

File

tests/src/Functional/LingotekNodeTabsThemeTest.php, line 23

Class

LingotekNodeTabsThemeTest
Tests the theme used in the Lingotek tabs for nodes.

Namespace

Drupal\Tests\lingotek\Functional

Code

protected function setUp() : void {
  parent::setUp();

  // Install themes theme.
  $theme_handler = $this->container
    ->get('theme_installer');
  $theme_handler
    ->install([
    'seven',
    'bartik',
  ]);
  $this
    ->config('system.theme')
    ->set('default', 'bartik')
    ->save();
  $edit = [];
  $edit['admin_theme'] = 'seven';
  $edit['use_admin_theme'] = TRUE;
  $this
    ->drupalPostForm('admin/appearance', $edit, t('Save configuration'));

  // Place the blocks.
  foreach ([
    'bartik',
    'seven',
  ] as $theme) {
    $this
      ->drupalPlaceBlock('page_title_block', [
      'region' => 'content',
      'weight' => -5,
      'theme' => $theme,
    ]);
    $this
      ->drupalPlaceBlock('local_tasks_block', [
      'region' => 'content',
      'weight' => -10,
      'theme' => $theme,
    ]);
    $this
      ->drupalPlaceBlock('current_theme_block', [
      'region' => 'content',
      'weight' => -15,
      'theme' => $theme,
    ]);
  }

  // Create Article node types.
  $this
    ->drupalCreateContentType([
    'type' => 'article',
    'name' => 'Article',
  ]);

  // Add a language.
  ConfigurableLanguage::createFromLangcode('es')
    ->setThirdPartySetting('lingotek', 'locale', 'es_MX')
    ->save();

  // Enable translation for the current entity type and ensure the change is
  // picked up.
  ContentLanguageSettings::loadByEntityTypeBundle('node', 'article')
    ->setLanguageAlterable(TRUE)
    ->save();
  \Drupal::service('content_translation.manager')
    ->setEnabled('node', 'article', TRUE);
  drupal_static_reset();
  \Drupal::entityTypeManager()
    ->clearCachedDefinitions();
  $this
    ->applyEntityUpdates();

  // Rebuild the container so that the new languages are picked up by services
  // that hold a list of languages.
  $this
    ->rebuildContainer();
  $this
    ->saveLingotekContentTranslationSettingsForNodeTypes();
}