How do I programatically enable transition in workflow

We want to test in Behat if a user can start transition with a guard. We set up a user with the role of “writer” and a transition with a “writer” guard. We inject a “workflow registry” and a “Token storage”.

We set a token:


Get our injected workflow

$workflow = $this->registry->get($product, 'story');

And try to apply a transition

$workflow->apply($product, ‘adding_pictures’);

When we run the test we get the following error:

Transition “adding_pictures” is not enabled for workflow “story”. (Symfony\Component\Workflow\Exception\NotEnabledTransitionException)

When we try to transition in the UI of pimcore we get no error and the products arrives in the right place. What is Pimcore doing different from our approach?