function WorkspaceTest::testWorkspaceFormRevisions

Same name in other branches
  1. 9 core/modules/workspaces/tests/src/Functional/WorkspaceTest.php \Drupal\Tests\workspaces\Functional\WorkspaceTest::testWorkspaceFormRevisions()
  2. 10 core/modules/workspaces/tests/src/Functional/WorkspaceTest.php \Drupal\Tests\workspaces\Functional\WorkspaceTest::testWorkspaceFormRevisions()
  3. 11.x core/modules/workspaces/tests/src/Functional/WorkspaceTest.php \Drupal\Tests\workspaces\Functional\WorkspaceTest::testWorkspaceFormRevisions()

Tests that editing a workspace creates a new revision.

File

core/modules/workspaces/tests/src/Functional/WorkspaceTest.php, line 135

Class

WorkspaceTest
Test the workspace entity.

Namespace

Drupal\Tests\workspaces\Functional

Code

public function testWorkspaceFormRevisions() {
    $this->drupalLogin($this->editor1);
    $storage = \Drupal::entityTypeManager()->getStorage('workspace');
    // The current 'stage' workspace entity should be revision 1.
    $stage_workspace = $storage->load('stage');
    $this->assertEquals('1', $stage_workspace->getRevisionId());
    // Re-save the 'stage' workspace via the UI to create revision 2.
    $this->drupalPostForm($stage_workspace->toUrl('edit-form')
        ->toString(), [], 'Save');
    $stage_workspace = $storage->loadUnchanged('stage');
    $this->assertEquals('2', $stage_workspace->getRevisionId());
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.