function TransitionTest::testFromAndTo

Same name in other branches
  1. 8.9.x core/modules/workflows/tests/src/Unit/TransitionTest.php \Drupal\Tests\workflows\Unit\TransitionTest::testFromAndTo()
  2. 10 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 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());
}

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