function WorkflowTest::testGetTransition
Same name in other branches
- 9 core/modules/workflows/tests/src/Unit/WorkflowTest.php \Drupal\Tests\workflows\Unit\WorkflowTest::testGetTransition()
- 8.9.x core/modules/workflows/tests/src/Unit/WorkflowTest.php \Drupal\Tests\workflows\Unit\WorkflowTest::testGetTransition()
- 10 core/modules/workflows/tests/src/Unit/WorkflowTest.php \Drupal\Tests\workflows\Unit\WorkflowTest::testGetTransition()
@covers ::getTransition
File
-
core/
modules/ workflows/ tests/ src/ Unit/ WorkflowTest.php, line 439
Class
- WorkflowTest
- @coversDefaultClass \Drupal\workflows\Plugin\WorkflowTypeBase
Namespace
Drupal\Tests\workflows\UnitCode
public function testGetTransition() : void {
$workflow = new Workflow([
'id' => 'test',
'type' => 'test_type',
], 'workflow');
// By default states are ordered in the order added.
$workflow->getTypePlugin()
->addState('draft', 'Draft')
->addState('published', 'Published')
->addState('archived', 'Archived')
->addTransition('create_new_draft', 'Create new draft', [
'draft',
], 'draft')
->addTransition('publish', 'Publish', [
'draft',
], 'published');
// Ensure we're returning state objects and they are set up correctly
$this->assertInstanceOf(Transition::class, $workflow->getTypePlugin()
->getTransition('create_new_draft'));
$this->assertEquals('publish', $workflow->getTypePlugin()
->getTransition('publish')
->id());
$this->assertEquals('Publish', $workflow->getTypePlugin()
->getTransition('publish')
->label());
$transition = $workflow->getTypePlugin()
->getTransition('publish');
$this->assertEquals($workflow->getTypePlugin()
->getState('draft'), $transition->from()['draft']);
$this->assertEquals($workflow->getTypePlugin()
->getState('published'), $transition->to());
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.