You are here

protected function ModerationSidebarTest::setUp in Moderation Sidebar 8

Same name in this branch
  1. 8 tests/src/Functional/ModerationSidebarTest.php \Drupal\Tests\moderation_sidebar\Functional\ModerationSidebarTest::setUp()
  2. 8 tests/src/FunctionalJavascript/ModerationSidebarTest.php \Drupal\Tests\moderation_sidebar\FunctionalJavascript\ModerationSidebarTest::setUp()

Overrides BrowserTestBase::setUp

File

tests/src/FunctionalJavascript/ModerationSidebarTest.php, line 34

Class

ModerationSidebarTest
Contains Moderation Sidebar integration tests.

Namespace

Drupal\Tests\moderation_sidebar\FunctionalJavascript

Code

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

  // Create a Content Type with moderation enabled.
  $node_type = $this
    ->drupalCreateContentType([
    'type' => 'article',
    'name' => 'Article',
  ]);

  /* @var \Drupal\workflows\WorkflowInterface $workflow */
  $workflow = $this->container
    ->get('entity_type.manager')
    ->getStorage('workflow')
    ->load('editorial');
  $workflow
    ->getTypePlugin()
    ->addEntityTypeAndBundle('node', 'article');
  $workflow
    ->save();
  $node_type
    ->setNewRevision(TRUE);
  $node_type
    ->save();

  // Create a user who can use the Moderation Sidebar.
  $user = $this
    ->drupalCreateUser([
    'access toolbar',
    'use moderation sidebar',
    'administer moderation sidebar',
    'access content',
    'create article content',
    'edit any article content',
    'delete any article content',
    'view any unpublished content',
    'view latest version',
    'use editorial transition create_new_draft',
    'use editorial transition publish',
    'create url aliases',
    'administer themes',
    'administer languages',
    'administer content translation',
    'create content translations',
    'update content translations',
    'delete content translations',
    'translate any entity',
  ]);
  $this
    ->drupalLogin($user);

  // Enable admin theme for content forms.
  $edit = [
    'use_admin_theme' => TRUE,
  ];
  $this
    ->drupalPostForm('admin/appearance', $edit, 'Save configuration');

  // Add German language.
  $edit = [
    'predefined_langcode' => 'de',
  ];
  $this
    ->drupalPostForm('admin/config/regional/language/add', $edit, t('Add language'));

  // Enable translations for nodes.
  $edit = [
    'entity_types[node]' => 'node',
    'settings[node][article][translatable]' => TRUE,
  ];
  $this
    ->drupalPostForm('admin/config/regional/content-language', $edit, 'Save configuration');
  drupal_flush_all_caches();
}