function StateTest::testGetTransitions

Same name in other branches
  1. 9 core/modules/workflows/tests/src/Unit/StateTest.php \Drupal\Tests\workflows\Unit\StateTest::testGetTransitions()
  2. 8.9.x core/modules/workflows/tests/src/Unit/StateTest.php \Drupal\Tests\workflows\Unit\StateTest::testGetTransitions()
  3. 10 core/modules/workflows/tests/src/Unit/StateTest.php \Drupal\Tests\workflows\Unit\StateTest::testGetTransitions()

@covers ::getTransitions

File

core/modules/workflows/tests/src/Unit/StateTest.php, line 83

Class

StateTest
@coversDefaultClass \Drupal\workflows\State

Namespace

Drupal\Tests\workflows\Unit

Code

public function testGetTransitions() : void {
    $workflow_type = new TestType([], '', []);
    $workflow_type->addState('draft', 'Draft')
        ->addState('published', 'Published')
        ->addState('archived', 'Archived')
        ->addTransition('create_new_draft', 'Create new draft', [
        'draft',
    ], 'draft')
        ->addTransition('publish', 'Publish', [
        'draft',
    ], 'published')
        ->addTransition('archive', 'Archive', [
        'published',
    ], 'archived');
    $state = $workflow_type->getState('draft');
    $transitions = $state->getTransitions();
    $this->assertCount(2, $transitions);
    $this->assertEquals('Create new draft', $transitions['create_new_draft']->label());
    $this->assertEquals('Publish', $transitions['publish']->label());
}

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