You are here

public function RequiredStatesTest::testGetRequiredStates in Drupal 10

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

@covers ::getRequiredStates @covers ::__construct

File

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

Class

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

Namespace

Drupal\Tests\workflows\Kernel

Code

public function testGetRequiredStates() {
  $workflow = Workflow::create([
    'id' => 'test',
    'type' => 'workflow_type_required_state_test',
  ]);
  $workflow
    ->save();
  $this
    ->assertEquals([
    'fresh',
    'rotten',
  ], $workflow
    ->getTypePlugin()
    ->getRequiredStates());

  // Ensure that the workflow has the default configuration.
  $this
    ->assertTrue($workflow
    ->getTypePlugin()
    ->hasState('rotten'));
  $this
    ->assertTrue($workflow
    ->getTypePlugin()
    ->hasState('fresh'));
  $this
    ->assertTrue($workflow
    ->getTypePlugin()
    ->hasTransitionFromStateToState('fresh', 'rotten'));
}