function TransitionTest::testFromAndTo

Same name and namespace in other branches
  1. 9 core/modules/workflows/tests/src/Unit/TransitionTest.php \Drupal\Tests\workflows\Unit\TransitionTest::testFromAndTo()
  2. 8.9.x core/modules/workflows/tests/src/Unit/TransitionTest.php \Drupal\Tests\workflows\Unit\TransitionTest::testFromAndTo()
  3. 11.x 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 40

Class

TransitionTest
@coversDefaultClass \Drupal\workflows\Transition[[api-linebreak]]

Namespace

Drupal\Tests\workflows\Unit

Code

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

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