public function testMenuLinksInDifferentWorkspaces() { MenuLinkContent::create(['menu_name' => 'main', 'link' => 'route:user.page', 'title' => 'Pineapple'])->save(); $this->drupalGet('user/2'); $this->assertLink('Pineapple'); $this->drupalGet('user/2', ['query' => ['workspace' => $this->new_workspace->id()]]); $this->assertNoLink('Pineapple'); // The previous page request only changed workspace for the session of the // request. We have to switch workspace in the test context as well. $this->workspaceManager->setActiveWorkspace($this->new_workspace); // Save another menu link. MenuLinkContent::create(['menu_name' => 'main', 'link' => 'route:user.page', 'title' => 'Pear'])->save(); $this->drupalGet('user/2'); $this->assertNoLink('Pineapple'); $this->assertLink('Pear'); // Switch back to the default workspace and ensure the menu links render // as expected. $this->drupalGet('user/2', ['query' => ['workspace' => 1]]); $this->assertLink('Pineapple'); $this->assertNoLink('Pear'); }
/** * {@inheritdoc} */ public function persist(WorkspaceInterface $workspace) { $_SESSION['workspace'] = $workspace->id(); return TRUE; }