You are here

public function StateTest::testGetTransitions in Drupal 8

Same name and namespace in other branches
  1. 9 core/modules/workflows/tests/src/Unit/StateTest.php \Drupal\Tests\workflows\Unit\StateTest::testGetTransitions()
  2. 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 81

Class

StateTest
@coversDefaultClass \Drupal\workflows\State

Namespace

Drupal\Tests\workflows\Unit

Code

public function testGetTransitions() {
  $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());
}