function WorkflowUiTest::testStateMachineNameValidation

Same name in other branches
  1. 9 core/modules/workflows/tests/src/Functional/WorkflowUiTest.php \Drupal\Tests\workflows\Functional\WorkflowUiTest::testStateMachineNameValidation()
  2. 8.9.x core/modules/workflows/tests/src/Functional/WorkflowUiTest.php \Drupal\Tests\workflows\Functional\WorkflowUiTest::testStateMachineNameValidation()
  3. 10 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() : void {
    Workflow::create([
        'id' => 'test_workflow',
        'label' => '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.');
}

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