You are here

public function WorkflowUiTest::testStateMachineNameValidation 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::testStateMachineNameValidation()

Tests the machine name validation of the state add form.

File

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

Class

WorkflowUiTest
Tests workflow creation UI.

Namespace

Drupal\Tests\workflows\Functional

Code

public function testStateMachineNameValidation() {
  Workflow::create([
    'id' => 'test_workflow',
    'type' => 'workflow_type_test',
  ])
    ->save();
  $this
    ->drupalLogin($this
    ->createUser([
    'administer workflows',
  ]));
  $this
    ->drupalGet('admin/config/workflow/workflows/manage/test_workflow/add_state');
  $this
    ->submitForm([
    'label' => 'Test State',
    'id' => 'Invalid ID',
  ], 'Save');
  $this
    ->assertSession()
    ->statusCodeEquals(200);
  $this
    ->assertSession()
    ->pageTextContains('The machine-readable name must contain only lowercase letters, numbers, and underscores.');
  $this
    ->drupalGet('admin/config/workflow/workflows/manage/test_workflow/add_transition');
  $this
    ->submitForm([
    'label' => 'Test Transition',
    'id' => 'Invalid ID',
  ], 'Save');
  $this
    ->assertSession()
    ->pageTextContains('The machine-readable name must contain only lowercase letters, numbers, and underscores.');
}