public function WorkspaceIntegrationTest::testDisallowedEntityUpdateInNonDefaultWorkspace in Drupal 8
Same name and namespace in other branches
- 9 core/modules/workspaces/tests/src/Kernel/WorkspaceIntegrationTest.php \Drupal\Tests\workspaces\Kernel\WorkspaceIntegrationTest::testDisallowedEntityUpdateInNonDefaultWorkspace()
- 10 core/modules/workspaces/tests/src/Kernel/WorkspaceIntegrationTest.php \Drupal\Tests\workspaces\Kernel\WorkspaceIntegrationTest::testDisallowedEntityUpdateInNonDefaultWorkspace()
Tests UPDATE operations for unsupported entity types.
@dataProvider providerTestAllowedEntityCrudInNonDefaultWorkspace
File
- core/
modules/ workspaces/ tests/ src/ Kernel/ WorkspaceIntegrationTest.php, line 621
Class
- WorkspaceIntegrationTest
- Tests a complete deployment scenario across different workspaces.
Namespace
Drupal\Tests\workspaces\KernelCode
public function testDisallowedEntityUpdateInNonDefaultWorkspace($entity_type_id, $allowed) {
$this
->initializeWorkspacesModule();
/** @var \Drupal\Core\Entity\ContentEntityStorageInterface $storage */
$storage = $this->entityTypeManager
->getStorage($entity_type_id);
// Create the entity in the default workspace.
$this->workspaceManager
->switchToLive();
$entity = $storage
->createWithSampleValues($entity_type_id);
if ($entity_type_id === 'workspace') {
$entity->id = 'test';
}
$entity
->save();
// Switch to a non-default workspace and check whether updating the entity
// is allowed.
$this
->switchToWorkspace('stage');
$entity->created->value = 1;
if (!$allowed) {
$this
->expectException(EntityStorageException::class);
$this
->expectExceptionMessage('This entity can only be saved in the default workspace.');
}
$entity
->save();
}