You are here

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

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

File

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

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());
}