function RequiredStatesTest::testDeleteRequiredStateAPI

@covers \Drupal\workflows\Entity\Workflow::preSave

File

core/modules/workflows/tests/src/Kernel/RequiredStatesTest.php, line 48

Class

RequiredStatesTest
Tests Workflow type's required states and configuration initialization.

Namespace

Drupal\Tests\workflows\Kernel

Code

public function testDeleteRequiredStateAPI() : void {
  $workflow = Workflow::create([
    'id' => 'test',
    'label' => 'Test workflow',
    'type' => 'workflow_type_required_state_test',
  ]);
  $workflow->save();
  // Ensure that required states can't be deleted.
  $this->expectException(RequiredStateMissingException::class);
  $this->expectExceptionMessage("Required State Type Test' requires states with the ID 'fresh' in workflow 'test'");
  $workflow->getTypePlugin()
    ->deleteState('fresh');
  $workflow->save();
}

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