You are here

public function WorkflowUiTest::testWorkflowConfigurationForm in Drupal 9

Same name and namespace in other branches
  1. 8 core/modules/workflows/tests/src/Functional/WorkflowUiTest.php \Drupal\Tests\workflows\Functional\WorkflowUiTest::testWorkflowConfigurationForm()

Tests the workflow configuration form.

File

core/modules/workflows/tests/src/Functional/WorkflowUiTest.php, line 290

Class

WorkflowUiTest
Tests workflow creation UI.

Namespace

Drupal\Tests\workflows\Functional

Code

public function testWorkflowConfigurationForm() {
  $workflow = Workflow::create([
    'id' => 'test',
    'type' => 'workflow_type_complex_test',
    'label' => 'Test',
  ]);
  $workflow
    ->getTypePlugin()
    ->addState('published', 'Published')
    ->addTransition('publish', 'Publish', [
    'published',
  ], 'published');
  $workflow
    ->save();
  $this
    ->drupalLogin($this
    ->createUser([
    'administer workflows',
  ]));

  // Add additional information to the workflow via the configuration form.
  $this
    ->drupalGet('admin/config/workflow/workflows/manage/test');
  $this
    ->assertSession()
    ->pageTextContains('Example global workflow setting');
  $this
    ->submitForm([
    'type_settings[example_setting]' => 'Extra global settings',
  ], 'Save');
  $workflow_storage = $this->container
    ->get('entity_type.manager')
    ->getStorage('workflow');
  $workflow = $workflow_storage
    ->loadUnchanged('test');
  $this
    ->assertEquals('Extra global settings', $workflow
    ->getTypePlugin()
    ->getConfiguration()['example_setting']);
}