diff --git a/src/Bundle/Builder/Action/ApplyTransitionAction.php b/src/Bundle/Builder/Action/ApplyTransitionAction.php new file mode 100644 index 00000000..e6600411 --- /dev/null +++ b/src/Bundle/Builder/Action/ApplyTransitionAction.php @@ -0,0 +1,34 @@ + [ + 'route' => $route, + 'parameters' => $routeParameters, + ], + 'transition' => $name, + ], $options); + + $action->setOptions($options); + + return $action; + } +} diff --git a/src/Bundle/spec/Builder/Action/ApplyTransitionActionSpec.php b/src/Bundle/spec/Builder/Action/ApplyTransitionActionSpec.php new file mode 100644 index 00000000..69ace56d --- /dev/null +++ b/src/Bundle/spec/Builder/Action/ApplyTransitionActionSpec.php @@ -0,0 +1,72 @@ +shouldHaveType(ApplyTransitionAction::class); + } + + function it_builds_apply_transition_actions(): void + { + $action = $this::create('publish', 'app_book_publish', ['id' => 'resource.id']); + + $action->shouldHaveType(ActionInterface::class); + $action->toArray()->shouldReturn([ + 'type' => 'apply_transition', + 'options' => [ + 'link' => [ + 'route' => 'app_book_publish', + 'parameters' => ['id' => 'resource.id'], + ], + 'transition' => 'publish', + ], + ]); + } + + function it_builds_apply_transition_with_options(): void + { + $action = $this::create( + 'publish', + 'app_book_publish', + [ + 'id' => 'resource.id', + ], + [ + 'class' => 'green', + 'graph' => 'sylius_book_publishing', + ], + ); + + $action->shouldHaveType(ActionInterface::class); + $action->toArray()->shouldReturn([ + 'type' => 'apply_transition', + 'options' => [ + 'link' => [ + 'route' => 'app_book_publish', + 'parameters' => ['id' => 'resource.id'], + ], + 'transition' => 'publish', + 'class' => 'green', + 'graph' => 'sylius_book_publishing', + ], + ]); + } +}