You are here

public function TransitionTest::testFromAndTo in Drupal 10

Same name and namespace in other branches
  1. 8 core/modules/workflows/tests/src/Unit/TransitionTest.php \Drupal\Tests\workflows\Unit\TransitionTest::testFromAndTo()
  2. 9 core/modules/workflows/tests/src/Unit/TransitionTest.php \Drupal\Tests\workflows\Unit\TransitionTest::testFromAndTo()

@covers ::from @covers ::to

File

core/modules/workflows/tests/src/Unit/TransitionTest.php, line 38

Class

TransitionTest
@coversDefaultClass \Drupal\workflows\Transition

Namespace

Drupal\Tests\workflows\Unit

Code

public function testFromAndTo() {
  $workflow = new TestType([], '', []);
  $workflow
    ->addState('draft', 'Draft')
    ->addState('published', 'Published')
    ->addTransition('publish', 'Publish', [
    'draft',
  ], 'published');
  $state = $workflow
    ->getState('draft');
  $transition = $state
    ->getTransitionTo('published');
  $this
    ->assertEquals($state, $transition
    ->from()['draft']);
  $this
    ->assertEquals($workflow
    ->getState('published'), $transition
    ->to());
}