public function WorkflowTest::testFindTransition in State Machine 8
@covers ::findTransition
File
- tests/
src/ Unit/ Plugin/ Workflow/ WorkflowTest.php, line 201
Class
- WorkflowTest
- @coversDefaultClass \Drupal\state_machine\Plugin\Workflow\Workflow @group state_machine
Namespace
Drupal\Tests\state_machine\Unit\Plugin\WorkflowCode
public function testFindTransition() {
$guard_factory = $this
->prophesize(GuardFactoryInterface::class);
$plugin_definition = [
'states' => [
'draft' => [
'label' => 'Draft',
],
'review' => [
'label' => 'Review',
],
'published' => [
'label' => 'Published',
],
],
'transitions' => [
'send_to_review' => [
'label' => 'Send to review',
'from' => [
'draft',
],
'to' => 'review',
],
'publish' => [
'label' => 'Publish',
'from' => [
'review',
],
'to' => 'published',
],
],
];
$workflow = new Workflow([], 'test', $plugin_definition, $guard_factory
->reveal());
$transition = $workflow
->getTransition('send_to_review');
$this
->assertEquals($transition, $workflow
->findTransition('draft', 'review'));
$this
->assertNull($workflow
->findTransition('foo', 'bar'));
}