function PathContentModerationTest::setUp

Same name and namespace in other branches
  1. 8.9.x core/modules/path/tests/src/Functional/PathContentModerationTest.php \Drupal\Tests\path\Functional\PathContentModerationTest::setUp()
  2. 10 core/modules/path/tests/src/Functional/PathContentModerationTest.php \Drupal\Tests\path\Functional\PathContentModerationTest::setUp()
  3. 11.x core/modules/path/tests/src/Functional/PathContentModerationTest.php \Drupal\Tests\path\Functional\PathContentModerationTest::setUp()

Overrides BrowserTestBase::setUp

File

core/modules/path/tests/src/Functional/PathContentModerationTest.php, line 39

Class

PathContentModerationTest
Tests path aliases with Content Moderation.

Namespace

Drupal\Tests\path\Functional

Code

protected function setUp() : void {
  parent::setUp();
  ConfigurableLanguage::createFromLangcode('fr')->save();
  $this->rebuildContainer();
  // Created a content type.
  $this->drupalCreateContentType([
    'name' => 'moderated',
    'type' => 'moderated',
  ]);
  // Set the content type as moderated.
  $workflow = $this->createEditorialWorkflow();
  $workflow->getTypePlugin()
    ->addEntityTypeAndBundle('node', 'moderated');
  $workflow->save();
  $this->drupalLogin($this->rootUser);
  // Enable URL language detection and selection.
  $edit = [
    'language_interface[enabled][language-url]' => 1,
  ];
  $this->drupalGet('admin/config/regional/language/detection');
  $this->submitForm($edit, 'Save settings');
  // Enable translation for moderated node.
  $edit = [
    'entity_types[node]' => 1,
    'settings[node][moderated][translatable]' => 1,
    'settings[node][moderated][fields][path]' => 1,
    'settings[node][moderated][fields][body]' => 1,
    'settings[node][moderated][settings][language][language_alterable]' => 1,
  ];
  $this->drupalGet('admin/config/regional/content-language');
  $this->submitForm($edit, 'Save configuration');
  \Drupal::entityTypeManager()->clearCachedDefinitions();
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.