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. 10 core/modules/workflows/tests/src/Functional/WorkflowUiTest.php \Drupal\Tests\workflows\Functional\WorkflowUiTest::testStateMachineNameValidation()
  3. 11.x core/modules/workflows/tests/src/Functional/WorkflowUiTest.php \Drupal\Tests\workflows\Functional\WorkflowUiTest::testStateMachineNameValidation()

Test 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->drupalPostForm('admin/config/workflow/workflows/manage/test_workflow/add_state', [
        '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->drupalPostForm('admin/config/workflow/workflows/manage/test_workflow/add_transition', [
        '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.