Commit 18176939 authored by catch's avatar catch
Browse files

Issue #3527314 by amateescu: Stop creating a "Stage" workspace by default on module installation

(cherry picked from commit 3436ff7d)
parent 81fee3b9
Loading
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -33,7 +33,7 @@ class WorkspaceContentModerationIntegrationTest extends ModerationStateTestBase
  protected function getAdministratorPermissions(): array {
    return array_merge($this->permissions, [
      'bypass node access',
      'view any workspace',
      'administer workspaces',
    ]);
  }

@@ -50,6 +50,7 @@ protected function setUp(): void {
    $this->createContentTypeFromUi('Article', 'article', TRUE);

    $this->setupWorkspaceSwitcherBlock();
    $this->createWorkspaceThroughUi('Stage', 'stage');
  }

  /**
+2 −1
Original line number Diff line number Diff line
@@ -15,6 +15,7 @@
 * JSON:API integration test for the "Workspace" content entity type.
 *
 * @group jsonapi
 * @group workspaces
 */
class WorkspaceTest extends ResourceTestBase {

@@ -142,7 +143,7 @@ protected function getExpectedDocument(): array {
          'changed' => (new \DateTime())->setTimestamp($this->entity->getChangedTime())->setTimezone(new \DateTimeZone('UTC'))->format(\DateTime::RFC3339),
          'label' => 'Campaign',
          'drupal_internal__id' => 'campaign',
          'drupal_internal__revision_id' => 2,
          'drupal_internal__revision_id' => 1,
        ],
        'relationships' => [
          'parent' => [
+5 −8
Original line number Diff line number Diff line
@@ -7,7 +7,6 @@
use Drupal\Tests\BrowserTestBase;
use Drupal\Tests\content_translation\Traits\ContentTranslationTestTrait;
use Drupal\Tests\WaitTerminateTestTrait;
use Drupal\workspaces\Entity\Workspace;

/**
 * Tests path aliases with workspaces.
@@ -91,9 +90,8 @@ public function testPathAliases(): void {
      'status' => TRUE,
    ]);

    // Switch to Stage and create an alias for the node.
    $stage = Workspace::load('stage');
    $this->switchToWorkspace($stage);
    // Activate a workspace and create an alias for the node.
    $stage = $this->createAndActivateWorkspaceThroughUi('Stage', 'stage');

    $edit = [
      'path[0][alias]' => '/' . $this->randomMachineName(),
@@ -131,9 +129,8 @@ public function testPathAliasesUserSwitch(): void {
      'status' => TRUE,
    ]);

    // Switch to Stage and create an alias for the node.
    $stage = Workspace::load('stage');
    $this->switchToWorkspace($stage);
    // Activate a workspace and create an alias for the node.
    $stage = $this->createAndActivateWorkspaceThroughUi('Stage', 'stage');

    $edit = [
      'path[0][alias]' => '/' . $this->randomMachineName(),
@@ -169,7 +166,7 @@ public function testPathAliasesUserSwitch(): void {
   * Tests path aliases with workspaces for translatable nodes.
   */
  public function testPathAliasesWithTranslation(): void {
    $stage = Workspace::load('stage');
    $stage = $this->createWorkspaceThroughUi('Stage', 'stage');

    // Create one node with a random alias.
    $default_node = $this->drupalCreateNode([
+1 −1
Original line number Diff line number Diff line
@@ -123,7 +123,7 @@ protected function getExpectedNormalizedEntity() {
      ],
      'revision_id' => [
        [
          'value' => 2,
          'value' => 1,
        ],
      ],
      'parent' => [],
+11 −6
Original line number Diff line number Diff line
@@ -66,17 +66,22 @@ public function testWorkspaceCacheContext(): void {
    $cache_bin = $variation_cache_factory->get($build['#cache']['bin']);
    $this->assertInstanceOf(\stdClass::class, $cache_bin->get($build['#cache']['keys'], CacheableMetadata::createFromRenderArray($build)));

    // Switch to the 'stage' workspace and check that the correct workspace
    // cache context is used.
    // Switch to the test workspace and check that the correct workspace cache
    // context is used.
    $test_user = $this->drupalCreateUser(['view any workspace']);
    $this->drupalLogin($test_user);

    $stage = Workspace::load('stage');
    $vultures = Workspace::create([
      'id' => 'vultures',
      'label' => 'Vultures',
    ]);
    $vultures->save();

    $workspace_manager = \Drupal::service('workspaces.manager');
    $workspace_manager->setActiveWorkspace($stage);
    $workspace_manager->setActiveWorkspace($vultures);

    $cache_context = new WorkspaceCacheContext($workspace_manager);
    $this->assertSame('stage', $cache_context->getContext());
    $this->assertSame('vultures', $cache_context->getContext());

    $build = \Drupal::entityTypeManager()->getViewBuilder('node')->view($node, 'full');

@@ -85,7 +90,7 @@ public function testWorkspaceCacheContext(): void {
    $this->assertContains('workspace', $build['#cache']['contexts']);

    $context_tokens = $cache_contexts_manager->convertTokensToKeys($build['#cache']['contexts'])->getKeys();
    $this->assertContains('[workspace]=stage', $context_tokens);
    $this->assertContains('[workspace]=vultures', $context_tokens);

    // Test that a cache entry is created.
    $cache_bin = $variation_cache_factory->get($build['#cache']['bin']);
Loading