function WorkflowTest::testAddStateException

Tests add state exception.

@legacy-covers ::addState

File

core/modules/workflows/tests/src/Unit/WorkflowTest.php, line 69

Class

WorkflowTest
Tests Drupal\workflows\Plugin\WorkflowTypeBase.

Namespace

Drupal\Tests\workflows\Unit

Code

public function testAddStateException() : void {
  $this->expectException(\InvalidArgumentException::class);
  $this->expectExceptionMessage("The state 'draft' already exists in workflow.");
  $workflow = new Workflow([
    'id' => 'test',
    'type' => 'test_type',
  ], 'workflow');
  $workflow->getTypePlugin()
    ->addState('draft', 'Draft');
  $workflow->getTypePlugin()
    ->addState('draft', 'Draft');
}

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