function StateTest::testGetTransitionToException

Same name and namespace in other branches
  1. 9 core/modules/workflows/tests/src/Unit/StateTest.php \Drupal\Tests\workflows\Unit\StateTest::testGetTransitionToException()
  2. 10 core/modules/workflows/tests/src/Unit/StateTest.php \Drupal\Tests\workflows\Unit\StateTest::testGetTransitionToException()
  3. 11.x core/modules/workflows/tests/src/Unit/StateTest.php \Drupal\Tests\workflows\Unit\StateTest::testGetTransitionToException()

@covers ::getTransitionTo

File

core/modules/workflows/tests/src/Unit/StateTest.php, line 69

Class

StateTest
@coversDefaultClass <a href="/api/drupal/core%21modules%21workflows%21src%21State.php/class/State/8.9.x" title="A value object representing a workflow state." class="local">\Drupal\workflows\State</a>

Namespace

Drupal\Tests\workflows\Unit

Code

public function testGetTransitionToException() {
    $this->expectException(\InvalidArgumentException::class);
    $this->expectExceptionMessage("Can not transition to 'published' state");
    $workflow_type = new TestType([], '', []);
    $workflow_type->addState('draft', 'Draft');
    $state = $workflow_type->getState('draft');
    $state->getTransitionTo('published');
}

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