You are here

public function StateItemTest::testSettableOptions in State Machine 8

@dataProvider providerSettableOptions

File

tests/src/Kernel/StateItemTest.php, line 124

Class

StateItemTest
@coversDefaultClass \Drupal\state_machine\Plugin\Field\FieldType\StateItem @group state_machine

Namespace

Drupal\Tests\state_machine\Kernel

Code

public function testSettableOptions($initial_state, $available_options) {
  $entity = EntityTestWithBundle::create([
    'type' => 'second',
    'field_state' => $initial_state,
  ]);
  $this
    ->assertEquals($initial_state, $entity
    ->get('field_state')->value);

  // An invalid state should not have any settable options.
  $this
    ->assertEquals($available_options, $entity
    ->get('field_state')
    ->first()
    ->getSettableOptions());
}