function WorkflowUiTest::testNumericIds

Same name in other branches
  1. 9 core/modules/workflows/tests/src/Functional/WorkflowUiTest.php \Drupal\Tests\workflows\Functional\WorkflowUiTest::testNumericIds()
  2. 10 core/modules/workflows/tests/src/Functional/WorkflowUiTest.php \Drupal\Tests\workflows\Functional\WorkflowUiTest::testNumericIds()
  3. 11.x core/modules/workflows/tests/src/Functional/WorkflowUiTest.php \Drupal\Tests\workflows\Functional\WorkflowUiTest::testNumericIds()

Test a workflow, state, and transition can have a numeric ID and label.

File

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

Class

WorkflowUiTest
Tests workflow creation UI.

Namespace

Drupal\Tests\workflows\Functional

Code

public function testNumericIds() {
    $this->drupalLogin($this->createUser([
        'administer workflows',
    ]));
    $this->drupalGet('admin/config/workflow/workflows');
    $this->clickLink('Add workflow');
    $this->submitForm([
        'label' => 123,
        'id' => 123,
        'workflow_type' => 'workflow_type_complex_test',
    ], 'Save');
    $this->assertSession()
        ->addressEquals('admin/config/workflow/workflows/manage/123/add_state');
    $this->submitForm([
        'label' => 456,
        'id' => 456,
    ], 'Save');
    $this->assertSession()
        ->pageTextContains('Created 456 state.');
    $this->clickLink('Add a new state');
    $this->submitForm([
        'label' => 789,
        'id' => 789,
    ], 'Save');
    $this->assertSession()
        ->pageTextContains('Created 789 state.');
    $this->clickLink('Add a new transition');
    $this->submitForm([
        'id' => 101112,
        'label' => 101112,
        'from[456]' => 456,
        'to' => 789,
    ], 'Save');
    $this->assertSession()
        ->pageTextContains('Created 101112 transition.');
    $workflow = $this->container
        ->get('entity_type.manager')
        ->getStorage('workflow')
        ->loadUnchanged(123);
    $this->assertEquals(123, $workflow->id());
    $this->assertEquals(456, $workflow->getTypePlugin()
        ->getState(456)
        ->id());
    $this->assertEquals(101112, $workflow->getTypePlugin()
        ->getTransition(101112)
        ->id());
    $this->assertEquals(789, $workflow->getTypePlugin()
        ->getTransition(101112)
        ->to()
        ->id());
}

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