function WorkspaceIntegrationTest::testCliPublishing

Same name and namespace in other branches
  1. 10 core/modules/workspaces/tests/src/Kernel/WorkspaceIntegrationTest.php \Drupal\Tests\workspaces\Kernel\WorkspaceIntegrationTest::testCliPublishing()

Tests workspace publishing as anonymous user, simulating a CLI request.

File

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

Class

WorkspaceIntegrationTest
Tests a complete publishing scenario across different workspaces.

Namespace

Drupal\Tests\workspaces\Kernel

Code

public function testCliPublishing() : void {
    $this->initializeWorkspacesModule();
    $this->switchToWorkspace('stage');
    // Add a workspace-specific revision to a pre-existing node.
    $node = $this->entityTypeManager
        ->getStorage('node')
        ->load(2);
    $node->title->value = 'stage - 2 - r3 - published';
    $node->save();
    // Switch to an anonymous user account and the 'Live' workspace.
    \Drupal::service('account_switcher')->switchTo(new AnonymousUserSession());
    \Drupal::service('workspaces.manager')->switchToLive();
    // Publish the workspace as anonymous, simulating a CLI request.
    $this->workspaces['stage']
        ->publish();
}

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