function RequiredStatesTest::testGetRequiredStates

Same name in other branches
  1. 8.9.x core/modules/workflows/tests/src/Kernel/RequiredStatesTest.php \Drupal\Tests\workflows\Kernel\RequiredStatesTest::testGetRequiredStates()
  2. 10 core/modules/workflows/tests/src/Kernel/RequiredStatesTest.php \Drupal\Tests\workflows\Kernel\RequiredStatesTest::testGetRequiredStates()
  3. 11.x 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'));
}

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