function WorkspaceTest::testWorkspaceFieldUi

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

Tests adding new fields to workspace entities.

File

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

Class

WorkspaceTest
Test the workspace entity.

Namespace

Drupal\Tests\workspaces\Functional

Code

public function testWorkspaceFieldUi() : void {
    $user = $this->drupalCreateUser([
        'administer workspaces',
        'access administration pages',
        'administer site configuration',
        'administer workspace fields',
        'administer workspace display',
        'administer workspace form display',
    ]);
    $this->drupalLogin($user);
    $this->drupalGet('admin/config/workflow/workspaces/fields');
    $this->assertSession()
        ->statusCodeEquals(200);
    // Create a new filed.
    $field_name = $this->randomMachineName();
    $field_label = $this->randomMachineName();
    $this->fieldUIAddNewField('admin/config/workflow/workspaces', $field_name, $field_label, 'string');
    // Check that the field is displayed on the manage form display page.
    $this->drupalGet('admin/config/workflow/workspaces/form-display');
    $this->assertSession()
        ->pageTextContains($field_label);
    // Check that the field is displayed on the manage display page.
    $this->drupalGet('admin/config/workflow/workspaces/display');
    $this->assertSession()
        ->pageTextContains($field_label);
}

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