public function StateTest::testCanTransitionTo in Drupal 8
Same name and namespace in other branches
- 9 core/modules/workflows/tests/src/Unit/StateTest.php \Drupal\Tests\workflows\Unit\StateTest::testCanTransitionTo()
- 10 core/modules/workflows/tests/src/Unit/StateTest.php \Drupal\Tests\workflows\Unit\StateTest::testCanTransitionTo()
@covers ::canTransitionTo
File
- core/
modules/ workflows/ tests/ src/ Unit/ StateTest.php, line 38
Class
- StateTest
- @coversDefaultClass \Drupal\workflows\State
Namespace
Drupal\Tests\workflows\UnitCode
public function testCanTransitionTo() {
$workflow_type = new TestType([], '', []);
$workflow_type
->addState('draft', 'Draft')
->addState('published', 'Published')
->addTransition('publish', 'Publish', [
'draft',
], 'published');
$state = $workflow_type
->getState('draft');
$this
->assertTrue($state
->canTransitionTo('published'));
$this
->assertFalse($state
->canTransitionTo('some_other_state'));
$workflow_type
->deleteTransition('publish');
$this
->assertFalse($state
->canTransitionTo('published'));
}