You are here

public function WorkflowTest::testGetStates in State Machine 8

@covers ::getStates @covers ::getState

File

tests/src/Unit/Plugin/Workflow/WorkflowTest.php, line 53

Class

WorkflowTest
@coversDefaultClass \Drupal\state_machine\Plugin\Workflow\Workflow @group state_machine

Namespace

Drupal\Tests\state_machine\Unit\Plugin\Workflow

Code

public function testGetStates() {
  $guard_factory = $this
    ->prophesize(GuardFactoryInterface::class);
  $plugin_definition = [
    'states' => [
      'draft' => [
        'label' => 'Draft',
      ],
    ],
    'transitions' => [],
  ];
  $workflow = new Workflow([], 'test', $plugin_definition, $guard_factory
    ->reveal());
  $state = $workflow
    ->getState('draft');
  $this
    ->assertEquals('draft', $state
    ->getId());
  $this
    ->assertEquals('Draft', $state
    ->getLabel());
  $this
    ->assertEquals([
    'draft' => $state,
  ], $workflow
    ->getStates());
}