You are here

public function RequiredStatesTest::testNoStatesRequiredStateAPI in Drupal 9

Same name and namespace in other branches
  1. 8 core/modules/workflows/tests/src/Kernel/RequiredStatesTest.php \Drupal\Tests\workflows\Kernel\RequiredStatesTest::testNoStatesRequiredStateAPI()
  2. 10 core/modules/workflows/tests/src/Kernel/RequiredStatesTest.php \Drupal\Tests\workflows\Kernel\RequiredStatesTest::testNoStatesRequiredStateAPI()

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

File

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

Class

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

Namespace

Drupal\Tests\workflows\Kernel

Code

public function testNoStatesRequiredStateAPI() {
  $workflow = new Workflow([
    'id' => 'test',
    'type' => 'workflow_type_required_state_test',
    'type_settings' => [
      'states' => [],
    ],
  ], 'workflow');
  $this
    ->expectException(RequiredStateMissingException::class);
  $this
    ->expectExceptionMessage("Required State Type Test' requires states with the ID 'fresh', 'rotten' in workflow 'test'");
  $workflow
    ->save();
}