function WorkspaceIntegrationTest::testCronRunsOutsideWorkspace

Tests that cron runs outside of workspace context.

File

core/modules/workspaces/tests/src/Kernel/WorkspaceIntegrationTest.php, line 1193

Class

WorkspaceIntegrationTest
Tests a complete publishing scenario across different workspaces.

Namespace

Drupal\Tests\workspaces\Kernel

Code

public function testCronRunsOutsideWorkspace() : void {
  $this->initializeWorkspacesModule();
  \Drupal::service('module_installer')->install([
    'workspaces_test',
  ]);
  // Switch to a workspace.
  $this->switchToWorkspace('stage');
  // Run cron while in the 'stage' workspace.
  \Drupal::service('cron')->run();
  // Check that cron ran without an active workspace.
  $recorded_workspace_id = \Drupal::keyValue('ws_test')->get('cron_active_workspace');
  $this->assertFalse($recorded_workspace_id, 'Cron should run without an active workspace.');
}

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