class ActiveWorkspaceUpdateTest
Same name and namespace in other branches
- 11.x core/modules/workspaces/tests/src/Functional/UpdateSystem/ActiveWorkspaceUpdateTest.php \Drupal\Tests\workspaces\Functional\UpdateSystem\ActiveWorkspaceUpdateTest
- 10 core/modules/workspaces/tests/src/Functional/UpdateSystem/ActiveWorkspaceUpdateTest.php \Drupal\Tests\workspaces\Functional\UpdateSystem\ActiveWorkspaceUpdateTest
- 8.9.x core/modules/workspaces/tests/src/Functional/UpdateSystem/ActiveWorkspaceUpdateTest.php \Drupal\Tests\workspaces\Functional\UpdateSystem\ActiveWorkspaceUpdateTest
Tests that there is no active workspace during database updates.
@group workspaces @group Update
Hierarchy
- class \Drupal\Tests\BrowserTestBase uses \Drupal\Core\Test\FunctionalTestSetupTrait, \Drupal\Tests\UiHelperTrait, \Drupal\Core\Test\TestSetupTrait, \Drupal\Tests\block\Traits\BlockCreationTrait, \Drupal\FunctionalTests\AssertLegacyTrait, \Drupal\Tests\RandomGeneratorTrait, \Drupal\Tests\node\Traits\NodeCreationTrait, \Drupal\Tests\node\Traits\ContentTypeCreationTrait, \Drupal\Tests\ConfigTestTrait, \Drupal\Tests\TestRequirementsTrait, \Drupal\Tests\user\Traits\UserCreationTrait, \Drupal\Tests\XdebugRequestTrait, \Drupal\Tests\Traits\PhpUnitWarnings, \Drupal\Tests\PhpUnitCompatibilityTrait, \Symfony\Bridge\PhpUnit\ExpectDeprecationTrait, \Drupal\Tests\ExtensionListTestTrait implements \PHPUnit\Framework\TestCase
- class \Drupal\Tests\workspaces\Functional\UpdateSystem\ActiveWorkspaceUpdateTest uses \Drupal\Tests\UpdatePathTestTrait, \Drupal\Tests\user\Traits\UserCreationTrait implements \Drupal\Tests\BrowserTestBase
Expanded class hierarchy of ActiveWorkspaceUpdateTest
File
-
core/
modules/ workspaces/ tests/ src/ Functional/ UpdateSystem/ ActiveWorkspaceUpdateTest.php, line 15
Namespace
Drupal\Tests\workspaces\Functional\UpdateSystemView source
class ActiveWorkspaceUpdateTest extends BrowserTestBase {
use UpdatePathTestTrait;
use UserCreationTrait;
/**
* {@inheritdoc}
*/
protected static $modules = [
'workspaces',
];
/**
* {@inheritdoc}
*/
protected $defaultTheme = 'stark';
/**
* {@inheritdoc}
*/
protected function setUp() : void {
parent::setUp();
$this->setUpCurrentUser([], [
'view any workspace',
]);
$this->container
->get('module_installer')
->install([
'workspace_update_test',
]);
$this->rebuildContainer();
// Ensure the workspace_update_test_post_update_check_active_workspace()
// update runs.
$existing_updates = \Drupal::keyValue('post_update')->get('existing_updates', []);
$index = array_search('workspace_update_test_post_update_check_active_workspace', $existing_updates);
unset($existing_updates[$index]);
\Drupal::keyValue('post_update')->set('existing_updates', $existing_updates);
}
/**
* Tests that there is no active workspace during database updates.
*/
public function testActiveWorkspaceDuringUpdate() {
/** @var \Drupal\workspaces\WorkspaceManagerInterface $workspace_manager */
$workspace_manager = \Drupal::service('workspaces.manager');
// Check that we have an active workspace before running the updates.
$this->assertTrue($workspace_manager->hasActiveWorkspace());
$this->assertEquals('test', $workspace_manager->getActiveWorkspace()
->id());
$this->runUpdates();
// Check that we didn't have an active workspace while running the updates.
// @see workspace_update_test_post_update_check_active_workspace()
$this->assertFalse(\Drupal::state()->get('workspace_update_test.has_active_workspace'));
// Check that we have an active workspace after running the updates.
$workspace_manager = \Drupal::service('workspaces.manager');
$this->assertTrue($workspace_manager->hasActiveWorkspace());
$this->assertEquals('test', $workspace_manager->getActiveWorkspace()
->id());
}
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.