setupWorkspaceSwitcherBlock example


    $this->drupalLogin($this->drupalCreateUser($permissions));
    $this->drupalPlaceBlock('system_menu_block:main');
  }

  /** * Tests custom menu links in non-default workspaces. */
  public function testWorkspacesWithCustomMenuLinks() {
    $stage = Workspace::load('stage');

    $this->setupWorkspaceSwitcherBlock();

    $default_title = 'default';
    $default_link = '#live';
    $menu_link_content = MenuLinkContent::create([
      'title' => $default_title,
      'menu_name' => 'main',
      'link' => [['uri' => 'internal:/' . $default_link]],
    ]);
    $menu_link_content->save();

    $pending_title = 'pending';
    
$stage_workspace = $storage->loadUnchanged('stage');
    $this->assertEquals('2', $stage_workspace->getRevisionId());
  }

  /** * Tests the manage workspace page. * * @group failing */
  public function testWorkspaceManagePage() {
    $this->drupalLogin($this->rootUser);
    $this->setupWorkspaceSwitcherBlock();
    $assert_session = $this->assertSession();

    $this->drupalCreateContentType(['type' => 'test', 'label' => 'Test']);
    $vocabulary = $this->createVocabulary();

    $test_1 = $this->createWorkspaceThroughUi('Test 1', 'test_1');
    $test_2 = $this->createWorkspaceThroughUi('Test 2', 'test_2');

    $this->switchToWorkspace($test_1);

    // Check that the 'test_1' workspace doesn't contain any changes initially.

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

    $permissions = [
      'create workspace',
      'edit own workspace',
      'view own workspace',
      'bypass entity access own workspace',
    ];

    $this->setupWorkspaceSwitcherBlock();

    $mayer = $this->drupalCreateUser($permissions);
    $this->drupalLogin($mayer);
  }

  /** * Tests switching workspace via the switcher block and admin page. */
  public function testSwitchingWorkspaces() {
    $vultures = $this->createWorkspaceThroughUi('Vultures', 'vultures');
    $this->switchToWorkspace($vultures);

    
/** * {@inheritdoc} */
  protected function setUp(): void {
    parent::setUp();

    $this->drupalLogin($this->rootUser);

    // Enable moderation on Article node type.     $this->createContentTypeFromUi('Article', 'article', TRUE);

    $this->setupWorkspaceSwitcherBlock();
  }

  /** * Tests moderating nodes in a workspace. */
  public function testModerationInWorkspace() {
    $stage = Workspace::load('stage');
    $this->switchToWorkspace($stage);

    // Create two nodes, a published and a draft one.     $this->drupalGet('node/add/article');
    
    $edit = [
      'entity_types[node]' => 1,
      'settings[node][article][translatable]' => 1,
      'settings[node][article][fields][path]' => 1,
      'settings[node][article][fields][body]' => 1,
      'settings[node][article][settings][language][language_alterable]' => 1,
    ];
    $this->drupalGet('admin/config/regional/content-language');
    $this->submitForm($edit, 'Save configuration');
    \Drupal::entityTypeManager()->clearCachedDefinitions();

    $this->setupWorkspaceSwitcherBlock();
  }

  /** * Tests path aliases with workspaces. */
  public function testPathAliases() {
    // Create a published node in Live, without an alias.     $node = $this->drupalCreateNode([
      'type' => 'article',
      'status' => TRUE,
    ]);

    

  public function testBypassOwnWorkspace() {
    $permissions = [
      'create workspace',
      'edit own workspace',
      'view own workspace',
      'bypass entity access own workspace',
    ];

    $this->createContentType(['type' => 'test', 'label' => 'Test']);
    $this->setupWorkspaceSwitcherBlock();

    $ditka = $this->drupalCreateUser(array_merge($permissions['create test content']));

    // Login as a limited-access user and create a workspace.     $this->drupalLogin($ditka);
    $bears = $this->createWorkspaceThroughUi('Bears', 'bears');
    $this->switchToWorkspace($bears);

    // Now create a node in the Bears workspace, as the owner of that workspace.     $ditka_bears_node = $this->createNodeThroughUi('Ditka Bears node', 'test');
    $ditka_bears_node_id = $ditka_bears_node->id();

    
/** * {@inheritdoc} */
  protected $defaultTheme = 'stark';

  /** * Tests editing a node in multiple workspaces. */
  public function testConcurrentEditing() {
    // Create a test node.     $this->createContentType(['type' => 'test', 'label' => 'Test']);
    $this->setupWorkspaceSwitcherBlock();

    $permissions = [
      'create workspace',
      'edit own workspace',
      'view own workspace',
      'create test content',
      'edit own test content',
    ];
    $mayer = $this->drupalCreateUser($permissions);
    $this->drupalLogin($mayer);

    
Home | Imprint | This part of the site doesn't use cookies.