You are here

protected function PathContentModerationTest::setUp in Drupal 9

Same name and namespace in other branches
  1. 8 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();
}