You are here

protected function ScheduledTransitionTest::setUp in Lightning Workflow 8.3

Same name and namespace in other branches
  1. 8.2 modules/lightning_scheduler/tests/src/Functional/ScheduledTransitionTest.php \Drupal\Tests\lightning_scheduler\Functional\ScheduledTransitionTest::setUp()

Overrides BrowserTestBase::setUp

File

modules/lightning_scheduler/tests/src/Functional/ScheduledTransitionTest.php, line 36

Class

ScheduledTransitionTest
@group lightning_workflow @group lightning_scheduler @group orca_public

Namespace

Drupal\Tests\lightning_scheduler\Functional

Code

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

  // The editorial workflow is packaged with Lightning Workflow, so install
  // its config but don't actually enable it since it is not a dependency.
  $this->container
    ->get('config.installer')
    ->installDefaultConfig('module', 'lightning_workflow');
  $this
    ->drupalCreateContentType([
    'type' => 'page',
  ]);

  // Due to a known core bug, rebuilding the node access table will break the
  // entity query in TransitionManager::getTransitionable(). The workaround is
  // for the query to specifically disable access checking, which it should be
  // doing anyway because transitions need to be processed irrespective of
  // user access.
  // @see https://www.drupal.org/project/drupal/issues/2823957
  node_access_rebuild();
  $workflow = Workflow::load('editorial');

  /** @var \Drupal\content_moderation\Plugin\WorkflowType\ContentModerationInterface $plugin */
  $plugin = $workflow
    ->getTypePlugin();
  $plugin
    ->addEntityTypeAndBundle('node', 'page');
  $workflow
    ->save();
  $account = $this
    ->drupalCreateUser([
    'create page content',
    'edit own page content',
    'view own unpublished content',
    'view latest version',
    'use editorial transition create_new_draft',
    'use editorial transition publish',
    'use editorial transition archive',
    'schedule editorial transition publish',
    'schedule editorial transition archive',
  ]);
  $this
    ->drupalLogin($account);
}