You are here

public function ContentModerationIntegration::setUp in Translation Views 8

Overrides ViewTestBase::setUp

File

tests/src/Functional/ContentModerationIntegration.php, line 43

Class

ContentModerationIntegration
Class ContentModerationIntegration.

Namespace

Drupal\Tests\translation_views\Functional

Code

public function setUp($import_test_views = TRUE) {

  // Inherit set up from the parent class.
  parent::setUp($import_test_views);

  // Login as a root user.
  $this
    ->drupalLogin($this->rootUser);

  // Import test views.
  ViewTestData::createTestViews(get_class($this), [
    'translation_views_test_views',
  ]);

  // Create additional languages.
  foreach (self::$langcodes as $langcode) {
    ConfigurableLanguage::createFromLangcode($langcode)
      ->save();
  }

  // Enable translation for article nodes.
  $this
    ->drupalPostForm('admin/config/regional/content-language', [
    "entity_types[node]" => 1,
    "settings[node][article][translatable]" => 1,
    "settings[node][article][settings][language][language_alterable]" => 1,
  ], 'Save configuration');

  // Flush definitions caches.
  \Drupal::entityTypeManager()
    ->clearCachedDefinitions();

  // Enable moderation state for article nodes.
  $workflow = Workflow::load('editorial');
  $workflow
    ->getTypePlugin()
    ->addEntityTypeAndBundle('node', 'article');
  $workflow
    ->save();

  // Logout.
  $this
    ->drupalLogout();
}