You are here

protected function ScheduledTransitionTest::setUp in Lightning Workflow 8.2

Same name and namespace in other branches
  1. 8.3 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 30

Class

ScheduledTransitionTest
@group lightning @group lightning_workflow @group lightning_scheduler

Namespace

Drupal\Tests\lightning_scheduler\Functional

Code

protected function setUp() {
  parent::setUp();
  $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',
    'use editorial transition archived_draft',
    'schedule editorial transition publish',
    'schedule editorial transition archive',
  ]);
  $this
    ->drupalLogin($account);
  $account
    ->set('timezone', 'America/New_York')
    ->save();
  $this
    ->config('system.date')
    ->set('timezone.default', 'America/New_York')
    ->save();
  date_default_timezone_set('UTC');
}