minor #31824 [Workflow] Remove BC layers and deprecated codes (lyrixx)

This PR was squashed before being merged into the 5.0-dev branch (closes #31824).

Discussion
----------

[Workflow] Remove BC layers and deprecated codes

| Q             | A
| ------------- | ---
| Branch?       | master
| Bug fix?      | no
| New feature?  | yes
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets |
| License       | MIT
| Doc PR        |

---

To do:

* [x] Component
* [x] Framework intergration

Commits
-------

cbb8b22753 [FrameworkBundle][Workflow] Remove BC layers and deprecated codes
08dc494294 [Workflow] Remove BC layers and deprecated codes
This commit is contained in:
Fabien Potencier 2019-06-05 08:19:46 +02:00
commit 9736403928
37 changed files with 62 additions and 1033 deletions

View File

@ -256,15 +256,6 @@ class Configuration implements ConfigurationInterface
->arrayNode('workflows')
->useAttributeAsKey('name')
->prototype('array')
->beforeNormalization()
->always(function ($v) {
if (isset($v['initial_place'])) {
$v['initial_marking'] = [$v['initial_place']];
}
return $v;
})
->end()
->fixXmlConfig('support')
->fixXmlConfig('place')
->fixXmlConfig('transition')
@ -277,28 +268,9 @@ class Configuration implements ConfigurationInterface
->defaultValue('state_machine')
->end()
->arrayNode('marking_store')
->fixXmlConfig('argument')
->children()
->enumNode('type')
->values(['multiple_state', 'single_state', 'method'])
->validate()
->ifTrue(function ($v) { return 'method' !== $v; })
->then(function ($v) {
@trigger_error('Passing something else than "method" has been deprecated in Symfony 4.3.', E_USER_DEPRECATED);
return $v;
})
->end()
->end()
->arrayNode('arguments')
->setDeprecated('The "%path%.%node%" configuration key has been deprecated in Symfony 4.3. Use "property" instead.')
->beforeNormalization()
->ifString()
->then(function ($v) { return [$v]; })
->end()
->requiresAtLeastOneElement()
->prototype('scalar')
->end()
->values(['method'])
->end()
->scalarNode('property')
->defaultValue('marking')
@ -307,14 +279,6 @@ class Configuration implements ConfigurationInterface
->cannotBeEmpty()
->end()
->end()
->validate()
->ifTrue(function ($v) { return isset($v['type']) && isset($v['service']); })
->thenInvalid('"type" and "service" cannot be used together.')
->end()
->validate()
->ifTrue(function ($v) { return !empty($v['arguments']) && isset($v['service']); })
->thenInvalid('"arguments" and "service" cannot be used together.')
->end()
->end()
->arrayNode('supports')
->beforeNormalization()
@ -332,10 +296,6 @@ class Configuration implements ConfigurationInterface
->scalarNode('support_strategy')
->cannotBeEmpty()
->end()
->scalarNode('initial_place')
->setDeprecated('The "%path%.%node%" configuration key has been deprecated in Symfony 4.3, use the "initial_marking" configuration key instead.')
->defaultNull()
->end()
->arrayNode('initial_marking')
->beforeNormalization()
->ifTrue(function ($v) { return !\is_array($v); })
@ -472,16 +432,6 @@ class Configuration implements ConfigurationInterface
})
->thenInvalid('"supports" or "support_strategy" should be configured.')
->end()
->validate()
->ifTrue(function ($v) {
return 'workflow' === $v['type'] && 'single_state' === ($v['marking_store']['type'] ?? false);
})
->then(function ($v) {
@trigger_error('Using a workflow with type=workflow and a marking_store=single_state is deprecated since Symfony 4.3. Use type=state_machine instead.', E_USER_DEPRECATED);
return $v;
})
->end()
->end()
->end()
->end()

View File

@ -627,7 +627,7 @@ class FrameworkExtension extends Extension
// Create places
$places = array_column($workflow['places'], 'name');
$initialMarking = $workflow['initial_marking'] ?? $workflow['initial_place'] ?? [];
$initialMarking = $workflow['initial_marking'] ?? [];
// Create a Definition
$definitionDefinition = new Definition(Workflow\Definition::class);
@ -639,17 +639,11 @@ class FrameworkExtension extends Extension
// Create MarkingStore
if (isset($workflow['marking_store']['type'])) {
$markingStoreDefinition = new ChildDefinition('workflow.marking_store.'.$workflow['marking_store']['type']);
if ('method' === $workflow['marking_store']['type']) {
$markingStoreDefinition->setArguments([
'state_machine' === $type, //single state
$workflow['marking_store']['property'],
]);
} else {
foreach ($workflow['marking_store']['arguments'] as $argument) {
$markingStoreDefinition->addArgument($argument);
}
}
$markingStoreDefinition = new ChildDefinition('workflow.marking_store.method');
$markingStoreDefinition->setArguments([
'state_machine' === $type, //single state
$workflow['marking_store']['property'],
]);
} elseif (isset($workflow['marking_store']['service'])) {
$markingStoreDefinition = new Reference($workflow['marking_store']['service']);
}
@ -668,29 +662,19 @@ class FrameworkExtension extends Extension
$container->registerAliasForArgument($workflowId, WorkflowInterface::class, $name.'.'.$type);
// Validate Workflow
$validator = null;
switch (true) {
case 'state_machine' === $workflow['type']:
$validator = new Workflow\Validator\StateMachineValidator();
break;
case 'single_state' === ($workflow['marking_store']['type'] ?? null):
$validator = new Workflow\Validator\WorkflowValidator(true);
break;
case 'multiple_state' === ($workflow['marking_store']['type'] ?? false):
$validator = new Workflow\Validator\WorkflowValidator(false);
break;
}
if ($validator) {
$realDefinition = (new Workflow\DefinitionBuilder($places))
->addTransitions(array_map(function (Reference $ref) use ($container): Workflow\Transition {
return $container->get((string) $ref);
}, $transitions))
->setInitialPlace($initialMarking)
->build()
;
$validator->validate($realDefinition, $name);
$realDefinition = (new Workflow\DefinitionBuilder($places))
->addTransitions(array_map(function (Reference $ref) use ($container): Workflow\Transition {
return $container->get((string) $ref);
}, $transitions))
->setInitialPlace($initialMarking)
->build()
;
if ('state_machine' === $workflow['type']) {
$validator = new Workflow\Validator\StateMachineValidator();
} else {
$validator = new Workflow\Validator\WorkflowValidator();
}
$validator->validate($realDefinition, $name);
// Add workflow to Registry
if ($workflow['supports']) {

View File

@ -20,8 +20,6 @@
<argument /> <!-- name -->
</service>
<service id="workflow.marking_store.multiple_state" class="Symfony\Component\Workflow\MarkingStore\MultipleStateMarkingStore" abstract="true" />
<service id="workflow.marking_store.single_state" class="Symfony\Component\Workflow\MarkingStore\SingleStateMarkingStore" abstract="true" />
<service id="workflow.marking_store.method" class="Symfony\Component\Workflow\MarkingStore\MethodMarkingStore" abstract="true" />
<service id="workflow.registry" class="Symfony\Component\Workflow\Registry" />

View File

@ -1,29 +0,0 @@
<?php
$container->loadFromExtension('framework', [
'workflows' => [
'legacy' => [
'type' => 'state_machine',
'marking_store' => [
'type' => 'single_state',
'arguments' => [
'state',
],
],
'supports' => [
stdClass::class,
],
'initial_place' => 'draft',
'places' => [
'draft',
'published',
],
'transitions' => [
'publish' => [
'from' => 'draft',
'to' => 'published',
],
],
],
],
]);

View File

@ -1,31 +0,0 @@
<?php
use Symfony\Bundle\FrameworkBundle\Tests\DependencyInjection\FrameworkExtensionTest;
$container->loadFromExtension('framework', [
'workflows' => [
'my_workflow' => [
'marking_store' => [
'arguments' => ['a', 'b'],
'service' => 'workflow_service',
],
'supports' => [
FrameworkExtensionTest::class,
],
'places' => [
'first',
'last',
],
'transitions' => [
'go' => [
'from' => [
'first',
],
'to' => [
'last',
],
],
],
],
],
]);

View File

@ -1,31 +0,0 @@
<?php
use Symfony\Bundle\FrameworkBundle\Tests\DependencyInjection\FrameworkExtensionTest;
$container->loadFromExtension('framework', [
'workflows' => [
'my_workflow' => [
'marking_store' => [
'type' => 'method',
'service' => 'workflow_service',
],
'supports' => [
FrameworkExtensionTest::class,
],
'places' => [
'first',
'last',
],
'transitions' => [
'go' => [
'from' => [
'first',
],
'to' => [
'last',
],
],
],
],
],
]);

View File

@ -10,8 +10,8 @@ $container->loadFromExtension('framework', [
'places' => ['bar', 'baz'],
'transitions' => [
'bar_baz' => [
'from' => ['foo'],
'to' => ['bar'],
'from' => ['bar'],
'to' => ['baz'],
],
],
],

View File

@ -10,8 +10,8 @@ $container->loadFromExtension('framework', [
'places' => ['bar', 'baz'],
'transitions' => [
'bar_baz' => [
'from' => ['foo'],
'to' => ['bar'],
'from' => ['bar'],
'to' => ['baz'],
],
],
],

View File

@ -1,23 +0,0 @@
<?xml version="1.0" ?>
<container xmlns="http://symfony.com/schema/dic/services"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:framework="http://symfony.com/schema/dic/symfony"
xsi:schemaLocation="http://symfony.com/schema/dic/services https://symfony.com/schema/dic/services/services-1.0.xsd
http://symfony.com/schema/dic/symfony https://symfony.com/schema/dic/symfony/symfony-1.0.xsd">
<framework:config>
<framework:workflow name="legacy" type="state_machine" initial-place="draft">
<framework:marking-store type="single_state">
<framework:argument>state</framework:argument>
</framework:marking-store>
<framework:support>stdClass</framework:support>
<framework:place name="draft" />
<framework:place name="published" />
<framework:transition name="publish">
<framework:from>draft</framework:from>
<framework:to>published</framework:to>
</framework:transition>
</framework:workflow>
</framework:config>
</container>

View File

@ -1,24 +0,0 @@
<?xml version="1.0" ?>
<container xmlns="http://symfony.com/schema/dic/services"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:framework="http://symfony.com/schema/dic/symfony"
xsi:schemaLocation="http://symfony.com/schema/dic/services https://symfony.com/schema/dic/services/services-1.0.xsd
http://symfony.com/schema/dic/symfony https://symfony.com/schema/dic/symfony/symfony-1.0.xsd">
<framework:config>
<framework:workflow name="my_workflow">
<framework:marking-store service="workflow_service">
<framework:argument>a</framework:argument>
<framework:argument>a</framework:argument>
</framework:marking-store>
<framework:support>Symfony\Bundle\FrameworkBundle\Tests\DependencyInjection\FrameworkExtensionTest</framework:support>
<framework:place name="first" />
<framework:place name="last" />
<framework:transition name="foobar">
<framework:from>a</framework:from>
<framework:to>a</framework:to>
</framework:transition>
</framework:workflow>
</framework:config>
</container>

View File

@ -1,21 +0,0 @@
<?xml version="1.0" ?>
<container xmlns="http://symfony.com/schema/dic/services"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:framework="http://symfony.com/schema/dic/symfony"
xsi:schemaLocation="http://symfony.com/schema/dic/services https://symfony.com/schema/dic/services/services-1.0.xsd
http://symfony.com/schema/dic/symfony https://symfony.com/schema/dic/symfony/symfony-1.0.xsd">
<framework:config>
<framework:workflow name="my_workflow">
<framework:marking-store type="method" service="workflow_service" />
<framework:support>Symfony\Bundle\FrameworkBundle\Tests\DependencyInjection\FrameworkExtensionTest</framework:support>
<framework:place name="first" />
<framework:place name="last" />
<framework:transition name="foobar">
<framework:from>a</framework:from>
<framework:to>a</framework:to>
</framework:transition>
</framework:workflow>
</framework:config>
</container>

View File

@ -6,7 +6,7 @@
http://symfony.com/schema/dic/symfony https://symfony.com/schema/dic/symfony/symfony-1.0.xsd">
<framework:config>
<framework:workflow enabled="true" name="foo" type="workflow" initial-marking="start">
<framework:workflow enabled="true" name="foo" type="workflow" initial-marking="bar">
<framework:support>Symfony\Bundle\FrameworkBundle\Tests\DependencyInjection\FrameworkExtensionTest</framework:support>
<framework:place>bar</framework:place>
<framework:place>baz</framework:place>

View File

@ -1,18 +0,0 @@
framework:
workflows:
legacy:
type: state_machine
marking_store:
type: single_state
arguments:
- state
initial_place: draft
supports:
- stdClass
places:
- draft
- published
transitions:
publish:
from: draft
to: published

View File

@ -1,19 +0,0 @@
framework:
workflows:
my_workflow:
marking_store:
arguments:
- a
- b
service: workflow_service
supports:
- Symfony\Bundle\FrameworkBundle\Tests\DependencyInjection\FrameworkExtensionTest
places:
- first
- last
transitions:
go:
from:
- first
to:
- last

View File

@ -1,17 +0,0 @@
framework:
workflows:
my_workflow:
marking_store:
type: method
service: workflow_service
supports:
- Symfony\Bundle\FrameworkBundle\Tests\DependencyInjection\FrameworkExtensionTest
places:
- first
- last
transitions:
go:
from:
- first
to:
- last

View File

@ -12,5 +12,5 @@ framework:
- baz
transitions:
bar_baz:
from: [foo]
from: [bar]
to: [bar]

View File

@ -11,5 +11,5 @@ framework:
- baz
transitions:
bar_baz:
from: [foo]
to: [bar]
from: [bar]
to: [baz]

View File

@ -278,31 +278,6 @@ abstract class FrameworkExtensionTest extends TestCase
$this->assertGreaterThan(0, \count($registryDefinition->getMethodCalls()));
}
/**
* @group legacy
*/
public function testWorkflowLegacy()
{
$container = $this->createContainerFromFile('workflow-legacy');
$this->assertTrue($container->hasDefinition('state_machine.legacy'), 'Workflow is registered as a service');
$this->assertSame('state_machine.abstract', $container->getDefinition('state_machine.legacy')->getParent());
$this->assertTrue($container->hasDefinition('state_machine.legacy.definition'), 'Workflow definition is registered as a service');
$workflowDefinition = $container->getDefinition('state_machine.legacy.definition');
$this->assertSame(['draft'], $workflowDefinition->getArgument(2));
$this->assertSame(
[
'draft',
'published',
],
$workflowDefinition->getArgument(0),
'Places are passed to the workflow definition'
);
}
/**
* @expectedException \Symfony\Component\Workflow\Exception\InvalidDefinitionException
* @expectedExceptionMessage A transition from a place/state must have an unique name. Multiple transitions named "go" from place/state "first" where found on StateMachine "my_workflow".
@ -312,15 +287,6 @@ abstract class FrameworkExtensionTest extends TestCase
$this->createContainerFromFile('workflow_not_valid');
}
/**
* @expectedException \Symfony\Component\Config\Definition\Exception\InvalidConfigurationException
* @expectedExceptionMessage "type" and "service" cannot be used together.
*/
public function testWorkflowCannotHaveBothTypeAndService()
{
$this->createContainerFromFile('workflow_legacy_with_type_and_service');
}
/**
* @expectedException \Symfony\Component\Config\Definition\Exception\InvalidConfigurationException
* @expectedExceptionMessage "supports" and "support_strategy" cannot be used together.
@ -339,16 +305,6 @@ abstract class FrameworkExtensionTest extends TestCase
$this->createContainerFromFile('workflow_without_support_and_support_strategy');
}
/**
* @expectedException \Symfony\Component\Config\Definition\Exception\InvalidConfigurationException
* @expectedExceptionMessage "arguments" and "service" cannot be used together.
* @group legacy
*/
public function testWorkflowCannotHaveBothArgumentsAndService()
{
$this->createContainerFromFile('workflow_legacy_with_arguments_and_service');
}
public function testWorkflowMultipleTransitionsWithSameName()
{
$container = $this->createContainerFromFile('workflow_with_multiple_transitions_with_same_name');
@ -450,14 +406,14 @@ abstract class FrameworkExtensionTest extends TestCase
$this->assertTrue($container->hasDefinition('console.command.workflow_dump'));
}
public function testExplicitlyEnabledWorkflows()
public function testWorkflowsExplicitlyEnabled()
{
$container = $this->createContainerFromFile('workflows_explicitly_enabled');
$this->assertTrue($container->hasDefinition('workflow.foo.definition'));
}
public function testExplicitlyEnabledWorkflowNamedWorkflows()
public function testWorkflowsNamedExplicitlyEnabled()
{
$container = $this->createContainerFromFile('workflows_explicitly_enabled_named_workflows');

View File

@ -87,112 +87,4 @@ class PhpFrameworkExtensionTest extends FrameworkExtensionTest
]);
});
}
/**
* @group legacy
* @expectedDeprecation Using a workflow with type=workflow and a marking_store=single_state is deprecated since Symfony 4.3. Use type=state_machine instead.
*/
public function testWorkflowDeprecateWorkflowSingleState()
{
$this->createContainerFromClosure(function ($container) {
$container->loadFromExtension('framework', [
'workflows' => [
'article' => [
'type' => 'workflow',
'marking_store' => [
'type' => 'single_state',
],
'supports' => [
__CLASS__,
],
'places' => [
'a',
'b',
'c',
],
'transitions' => [
'a_to_b' => [
'from' => ['a'],
'to' => ['b'],
],
],
],
],
]);
});
}
/**
* @group legacy
*/
public function testWorkflowValidationMultipleState()
{
$this->createContainerFromClosure(function ($container) {
$container->loadFromExtension('framework', [
'workflows' => [
'article' => [
'type' => 'workflow',
'marking_store' => [
'type' => 'multiple_state',
],
'supports' => [
__CLASS__,
],
'places' => [
'a',
'b',
'c',
],
'transitions' => [
'a_to_b' => [
'from' => ['a'],
'to' => ['b', 'c'],
],
],
],
],
]);
});
// the test ensures that the validation does not fail (i.e. it does not throw any exceptions)
$this->addToAssertionCount(1);
}
/**
* @expectedException \Symfony\Component\Workflow\Exception\InvalidDefinitionException
* @expectedExceptionMessage The marking store of workflow "article" can not store many places. But the transition "a_to_b" has too many output (2). Only one is accepted.
* @group legacy
*/
public function testWorkflowValidationSingleState()
{
$this->createContainerFromClosure(function ($container) {
$container->loadFromExtension('framework', [
'workflows' => [
'article' => [
'type' => 'workflow',
'marking_store' => [
'type' => 'single_state',
],
'supports' => [
__CLASS__,
],
'places' => [
'a',
'b',
'c',
],
'transitions' => [
'a_to_b' => [
'from' => ['a'],
'to' => ['b', 'c'],
],
],
],
],
]);
});
// the test ensures that the validation does not fail (i.e. it does not throw any exceptions)
$this->addToAssertionCount(1);
}
}

View File

@ -47,22 +47,6 @@ final class Definition
$this->metadataStore = $metadataStore ?: new InMemoryMetadataStore();
}
/**
* @deprecated since Symfony 4.3. Use the getInitialPlaces() instead.
*
* @return string|null
*/
public function getInitialPlace()
{
@trigger_error(sprintf('Calling %s::getInitialPlace() is deprecated. Call %s::getInitialPlaces() instead.', __CLASS__, __CLASS__));
if (!$this->initialPlaces) {
return null;
}
return reset($this->initialPlaces);
}
/**
* @return string[]
*/

View File

@ -135,16 +135,4 @@ class DefinitionBuilder
return $this;
}
/**
* @deprecated since Symfony 4.1, use the clear() method instead.
*
* @return $this
*/
public function reset()
{
@trigger_error(sprintf('The "%s()" method is deprecated since Symfony 4.1, use the "clear()" method instead.', __METHOD__), E_USER_DEPRECATED);
return $this->clear();
}
}

View File

@ -1,70 +0,0 @@
<?php
/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Component\Workflow\DependencyInjection;
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Exception\RuntimeException;
use Symfony\Component\Workflow\Validator\StateMachineValidator;
use Symfony\Component\Workflow\Validator\WorkflowValidator;
/**
* @author Tobias Nyholm <tobias.nyholm@gmail.com>
*
* @deprecated since Symfony 4.3
*/
class ValidateWorkflowsPass implements CompilerPassInterface
{
private $definitionTag;
public function __construct(string $definitionTag = 'workflow.definition')
{
$this->definitionTag = $definitionTag;
}
public function process(ContainerBuilder $container)
{
$taggedServices = $container->findTaggedServiceIds($this->definitionTag, true);
foreach ($taggedServices as $id => $tags) {
foreach ($tags as $tag) {
if (!\array_key_exists('name', $tag)) {
throw new RuntimeException(sprintf('The "name" for the tag "%s" of service "%s" must be set.', $this->definitionTag, $id));
}
if (!\array_key_exists('type', $tag)) {
throw new RuntimeException(sprintf('The "type" for the tag "%s" of service "%s" must be set.', $this->definitionTag, $id));
}
if (!\array_key_exists('marking_store', $tag)) {
throw new RuntimeException(sprintf('The "marking_store" for the tag "%s" of service "%s" must be set.', $this->definitionTag, $id));
}
$this->createValidator($tag)->validate($container->get($id), $tag['name']);
}
}
}
private function createValidator($tag)
{
if ('state_machine' === $tag['type']) {
return new StateMachineValidator();
}
if ('single_state' === $tag['marking_store']) {
return new WorkflowValidator(true);
}
if ('multiple_state' === $tag['marking_store']) {
return new WorkflowValidator(false);
}
return new WorkflowValidator($tag['single_state'] ?? false);
}
}

View File

@ -26,30 +26,16 @@ class Event extends BaseEvent
private $marking;
private $transition;
private $workflow;
private $workflowName;
/**
* @param object $subject
* @param Marking $marking
* @param Transition $transition
* @param WorkflowInterface $workflow
* @param object $subject
*/
public function __construct($subject, Marking $marking, Transition $transition = null, $workflow = null)
public function __construct($subject, Marking $marking, Transition $transition = null, WorkflowInterface $workflow = null)
{
$this->subject = $subject;
$this->marking = $marking;
$this->transition = $transition;
if (null === $workflow) {
@trigger_error(sprintf('Passing only three parameters to "%s" is deprecated since Symfony 4.1. Pass a %s instance as fourth parameter instead.', __METHOD__, WorkflowInterface::class), E_USER_DEPRECATED);
$this->workflowName = 'unnamed';
} elseif (\is_string($workflow)) {
@trigger_error(sprintf('Passing a string as the 4th parameter of "%s()" is deprecated since Symfony 4.1. Pass a %s instance instead.', __METHOD__, WorkflowInterface::class), E_USER_DEPRECATED);
$this->workflowName = $workflow;
} elseif ($workflow instanceof WorkflowInterface) {
$this->workflow = $workflow;
} else {
throw new \TypeError(sprintf('The 4th parameter of "%s" should be a "%s" instance instead.', __METHOD__, WorkflowInterface::class));
}
$this->workflow = $workflow;
}
public function getMarking()
@ -69,36 +55,16 @@ class Event extends BaseEvent
public function getWorkflow(): WorkflowInterface
{
// BC layer
if (!$this->workflow instanceof WorkflowInterface) {
throw new \RuntimeException(sprintf('The 4th parameter of "%s"::__construct() should be a "%s" instance.', __CLASS__, WorkflowInterface::class));
}
return $this->workflow;
}
public function getWorkflowName()
{
// BC layer
if ($this->workflowName) {
return $this->workflowName;
}
// BC layer
if (!$this->workflow instanceof WorkflowInterface) {
throw new \RuntimeException(sprintf('The 4th parameter of "%s"::__construct() should be a "%s" instance.', __CLASS__, WorkflowInterface::class));
}
return $this->workflow->getName();
}
public function getMetadata(string $key, $subject)
{
// BC layer
if (!$this->workflow instanceof WorkflowInterface) {
throw new \RuntimeException(sprintf('The 4th parameter of "%s"::__construct() should be a "%s" instance.', __CLASS__, WorkflowInterface::class));
}
return $this->workflow->getMetadataStore()->getMetadata($key, $subject);
}
}

View File

@ -80,17 +80,11 @@ class GuardListener
throw new InvalidTokenConfigurationException(sprintf('There are no tokens available for workflow %s.', $event->getWorkflowName()));
}
$roleNames = $token->getRoleNames();
if (null !== $this->roleHierarchy) {
$roleNames = $this->roleHierarchy->getReachableRoleNames($roleNames);
}
$variables = [
'token' => $token,
'user' => $token->getUser(),
'subject' => $event->getSubject(),
'role_names' => $roleNames,
'role_names' => $this->roleHierarchy->getReachableRoleNames($token->getRoleNames()),
// needed for the is_granted expression function
'auth_checker' => $this->authorizationChecker,
// needed for the is_* expression function

View File

@ -1,67 +0,0 @@
<?php
/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Component\Workflow\MarkingStore;
@trigger_error(sprintf('"%s" is deprecated since Symfony 4.3, use "%s" instead.', MultipleStateMarkingStore::class, MethodMarkingStore::class), E_USER_DEPRECATED);
use Symfony\Component\PropertyAccess\PropertyAccess;
use Symfony\Component\PropertyAccess\PropertyAccessorInterface;
use Symfony\Component\Workflow\Marking;
/**
* MultipleStateMarkingStore stores the marking into a property of the
* subject.
*
* This store deals with a "multiple state" Marking. It means a subject can be
* in many states at the same time.
*
* @deprecated since Symfony 4.3, use MethodMarkingStore instead.
*
* @author Grégoire Pineau <lyrixx@lyrixx.info>
*/
class MultipleStateMarkingStore implements MarkingStoreInterface
{
private $property;
private $propertyAccessor;
public function __construct(string $property = 'marking', PropertyAccessorInterface $propertyAccessor = null)
{
$this->property = $property;
$this->propertyAccessor = $propertyAccessor ?: PropertyAccess::createPropertyAccessor();
}
/**
* {@inheritdoc}
*/
public function getMarking($subject)
{
return new Marking($this->propertyAccessor->getValue($subject, $this->property) ?: []);
}
/**
* {@inheritdoc}
*
* @param array $context Some context
*/
public function setMarking($subject, Marking $marking/*, array $context = []*/)
{
$this->propertyAccessor->setValue($subject, $this->property, $marking->getPlaces());
}
/**
* @return string
*/
public function getProperty()
{
return $this->property;
}
}

View File

@ -1,72 +0,0 @@
<?php
/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Component\Workflow\MarkingStore;
@trigger_error(sprintf('"%s" is deprecated since Symfony 4.3, use "%s" instead.', SingleStateMarkingStore::class, MethodMarkingStore::class), E_USER_DEPRECATED);
use Symfony\Component\PropertyAccess\PropertyAccess;
use Symfony\Component\PropertyAccess\PropertyAccessorInterface;
use Symfony\Component\Workflow\Marking;
/**
* SingleStateMarkingStore stores the marking into a property of the subject.
*
* This store deals with a "single state" Marking. It means a subject can be in
* one and only one state at the same time.
*
* @deprecated since Symfony 4.3, use MethodMarkingStore instead.
*
* @author Grégoire Pineau <lyrixx@lyrixx.info>
*/
class SingleStateMarkingStore implements MarkingStoreInterface
{
private $property;
private $propertyAccessor;
public function __construct(string $property = 'marking', PropertyAccessorInterface $propertyAccessor = null)
{
$this->property = $property;
$this->propertyAccessor = $propertyAccessor ?: PropertyAccess::createPropertyAccessor();
}
/**
* {@inheritdoc}
*/
public function getMarking($subject)
{
$placeName = $this->propertyAccessor->getValue($subject, $this->property);
if (!$placeName) {
return new Marking();
}
return new Marking([$placeName => 1]);
}
/**
* {@inheritdoc}
*
* @param array $context Some context
*/
public function setMarking($subject, Marking $marking/*, array $context = []*/)
{
$this->propertyAccessor->setValue($subject, $this->property, key($marking->getPlaces()));
}
/**
* @return string
*/
public function getProperty()
{
return $this->property;
}
}

View File

@ -12,7 +12,6 @@
namespace Symfony\Component\Workflow;
use Symfony\Component\Workflow\Exception\InvalidArgumentException;
use Symfony\Component\Workflow\SupportStrategy\SupportStrategyInterface;
use Symfony\Component\Workflow\SupportStrategy\WorkflowSupportStrategyInterface;
/**
@ -23,18 +22,6 @@ class Registry
{
private $workflows = [];
/**
* @param Workflow $workflow
* @param SupportStrategyInterface $supportStrategy
*
* @deprecated since Symfony 4.1, use addWorkflow() instead
*/
public function add(Workflow $workflow, $supportStrategy)
{
@trigger_error(sprintf('The "%s()" method is deprecated since Symfony 4.1. Use addWorkflow() instead.', __METHOD__), E_USER_DEPRECATED);
$this->workflows[] = [$workflow, $supportStrategy];
}
public function addWorkflow(WorkflowInterface $workflow, WorkflowSupportStrategyInterface $supportStrategy)
{
$this->workflows[] = [$workflow, $supportStrategy];

View File

@ -22,6 +22,6 @@ class StateMachine extends Workflow
{
public function __construct(Definition $definition, MarkingStoreInterface $markingStore = null, EventDispatcherInterface $dispatcher = null, string $name = 'unnamed')
{
parent::__construct($definition, $markingStore ?: new MethodMarkingStore(true, 'marking'), $dispatcher, $name);
parent::__construct($definition, $markingStore ?: new MethodMarkingStore(true), $dispatcher, $name);
}
}

View File

@ -1,47 +0,0 @@
<?php
/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Component\Workflow\SupportStrategy;
@trigger_error(sprintf('"%s" is deprecated since Symfony 4.1. Use "%s" instead.', ClassInstanceSupportStrategy::class, InstanceOfSupportStrategy::class), E_USER_DEPRECATED);
use Symfony\Component\Workflow\Workflow;
/**
* @author Andreas Kleemann <akleemann@inviqa.com>
*
* @deprecated since Symfony 4.1, use InstanceOfSupportStrategy instead
*/
final class ClassInstanceSupportStrategy implements SupportStrategyInterface
{
private $className;
public function __construct(string $className)
{
$this->className = $className;
}
/**
* {@inheritdoc}
*/
public function supports(Workflow $workflow, $subject)
{
return $subject instanceof $this->className;
}
/**
* @return string
*/
public function getClassName()
{
return $this->className;
}
}

View File

@ -1,30 +0,0 @@
<?php
/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Component\Workflow\SupportStrategy;
use Symfony\Component\Workflow\Workflow;
/**
* @author Andreas Kleemann <akleemann@inviqa.com>
*
* @deprecated since Symfony 4.1, use WorkflowSupportStrategyInterface instead
*/
interface SupportStrategyInterface
{
/**
* @param Workflow $workflow
* @param object $subject
*
* @return bool
*/
public function supports(Workflow $workflow, $subject);
}

View File

@ -7,11 +7,12 @@ use Symfony\Component\Security\Core\Authentication\AuthenticationTrustResolverIn
use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface;
use Symfony\Component\Security\Core\Authentication\Token\UsernamePasswordToken;
use Symfony\Component\Security\Core\Authorization\AuthorizationCheckerInterface;
use Symfony\Component\Security\Core\Role\RoleHierarchy;
use Symfony\Component\Validator\Validator\ValidatorInterface;
use Symfony\Component\Workflow\Event\GuardEvent;
use Symfony\Component\Workflow\EventListener\ExpressionLanguage;
use Symfony\Component\Workflow\EventListener\GuardExpression;
use Symfony\Component\Workflow\EventListener\GuardListener;
use Symfony\Component\Workflow\Event\GuardEvent;
use Symfony\Component\Workflow\Marking;
use Symfony\Component\Workflow\Tests\Subject;
use Symfony\Component\Workflow\Transition;
@ -41,7 +42,8 @@ class GuardListenerTest extends TestCase
$this->authenticationChecker = $this->getMockBuilder(AuthorizationCheckerInterface::class)->getMock();
$trustResolver = $this->getMockBuilder(AuthenticationTrustResolverInterface::class)->getMock();
$this->validator = $this->getMockBuilder(ValidatorInterface::class)->getMock();
$this->listener = new GuardListener($this->configuration, $expressionLanguage, $tokenStorage, $this->authenticationChecker, $trustResolver, null, $this->validator);
$roleHierarchy = new RoleHierarchy([]);
$this->listener = new GuardListener($this->configuration, $expressionLanguage, $tokenStorage, $this->authenticationChecker, $trustResolver, $roleHierarchy, $this->validator);
}
protected function tearDown()

View File

@ -1,34 +0,0 @@
<?php
namespace Symfony\Component\Workflow\Tests\MarkingStore;
use PHPUnit\Framework\TestCase;
use Symfony\Component\Workflow\Marking;
use Symfony\Component\Workflow\MarkingStore\MultipleStateMarkingStore;
/** @group legacy*/
class MultipleStateMarkingStoreTest extends TestCase
{
public function testGetSetMarking()
{
$subject = new \stdClass();
$subject->myMarks = null;
$markingStore = new MultipleStateMarkingStore('myMarks');
$marking = $markingStore->getMarking($subject);
$this->assertInstanceOf(Marking::class, $marking);
$this->assertCount(0, $marking->getPlaces());
$marking->mark('first_place');
$markingStore->setMarking($subject, $marking);
$this->assertSame(['first_place' => 1], $subject->myMarks);
$marking2 = $markingStore->getMarking($subject);
$this->assertEquals($marking, $marking2);
}
}

View File

@ -1,34 +0,0 @@
<?php
namespace Symfony\Component\Workflow\Tests\MarkingStore;
use PHPUnit\Framework\TestCase;
use Symfony\Component\Workflow\Marking;
use Symfony\Component\Workflow\MarkingStore\SingleStateMarkingStore;
/** @group legacy*/
class SingleStateMarkingStoreTest extends TestCase
{
public function testGetSetMarking()
{
$subject = new \stdClass();
$subject->myMarks = null;
$markingStore = new SingleStateMarkingStore('myMarks');
$marking = $markingStore->getMarking($subject);
$this->assertInstanceOf(Marking::class, $marking);
$this->assertCount(0, $marking->getPlaces());
$marking->mark('first_place');
$markingStore->setMarking($subject, $marking);
$this->assertSame('first_place', $subject->myMarks);
$marking2 = $markingStore->getMarking($subject);
$this->assertEquals($marking, $marking2);
}
}

View File

@ -29,21 +29,6 @@ class RegistryTest extends TestCase
$this->registry = null;
}
/**
* @group legacy
* @expectedDeprecation The "Symfony\Component\Workflow\Registry::add()" method is deprecated since Symfony 4.1. Use addWorkflow() instead.
*/
public function testAddIsDeprecated()
{
$registry = new Registry();
$registry->add($w = new Workflow(new Definition([], []), $this->getMockBuilder(MarkingStoreInterface::class)->getMock(), $this->getMockBuilder(EventDispatcherInterface::class)->getMock(), 'workflow1'), $this->createSupportStrategy(Subject1::class));
$workflow = $registry->get(new Subject1());
$this->assertInstanceOf(Workflow::class, $workflow);
$this->assertSame('workflow1', $workflow->getName());
}
public function testGetWithSuccess()
{
$workflow = $this->registry->get(new Subject1());
@ -108,23 +93,6 @@ class RegistryTest extends TestCase
$this->assertCount(0, $workflows);
}
/**
* @group legacy
*/
private function createSupportStrategy($supportedClassName)
{
$strategy = $this->getMockBuilder(SupportStrategyInterface::class)->getMock();
$strategy->expects($this->any())->method('supports')
->willReturnCallback(function ($workflow, $subject) use ($supportedClassName) {
return $subject instanceof $supportedClassName;
});
return $strategy;
}
/**
* @group legacy
*/
private function createWorkflowSupportStrategy($supportedClassName)
{
$strategy = $this->getMockBuilder(WorkflowSupportStrategyInterface::class)->getMock();

View File

@ -1,37 +0,0 @@
<?php
namespace Symfony\Component\Workflow\Tests\SupportStrategy;
use PHPUnit\Framework\TestCase;
use Symfony\Component\Workflow\SupportStrategy\ClassInstanceSupportStrategy;
use Symfony\Component\Workflow\Workflow;
/**
* @group legacy
*/
class ClassInstanceSupportStrategyTest extends TestCase
{
/**
* @expectedDeprecation "Symfony\Component\Workflow\SupportStrategy\ClassInstanceSupportStrategy" is deprecated since Symfony 4.1. Use "Symfony\Component\Workflow\SupportStrategy\InstanceOfSupportStrategy" instead.
*/
public function testSupportsIfClassInstance()
{
$strategy = new ClassInstanceSupportStrategy('Symfony\Component\Workflow\Tests\SupportStrategy\Subject1');
$this->assertTrue($strategy->supports($this->createWorkflow(), new Subject1()));
}
public function testSupportsIfNotClassInstance()
{
$strategy = new ClassInstanceSupportStrategy('Symfony\Component\Workflow\Tests\SupportStrategy\Subject2');
$this->assertFalse($strategy->supports($this->createWorkflow(), new Subject1()));
}
private function createWorkflow()
{
return $this->getMockBuilder(Workflow::class)
->disableOriginalConstructor()
->getMock();
}
}

View File

@ -12,27 +12,6 @@ class WorkflowValidatorTest extends TestCase
{
use WorkflowBuilderTrait;
/**
* @expectedException \Symfony\Component\Workflow\Exception\InvalidDefinitionException
* @expectedExceptionMessage The marking store of workflow "foo" can not store many places.
*/
public function testSinglePlaceWorkflowValidatorAndComplexWorkflow()
{
$definition = $this->createComplexWorkflowDefinition();
(new WorkflowValidator(true))->validate($definition, 'foo');
}
public function testSinglePlaceWorkflowValidatorAndSimpleWorkflow()
{
$definition = $this->createSimpleWorkflowDefinition();
(new WorkflowValidator(true))->validate($definition, 'foo');
// the test ensures that the validation does not fail (i.e. it does not throw any exceptions)
$this->addToAssertionCount(1);
}
/**
* @expectedException \Symfony\Component\Workflow\Exception\InvalidDefinitionException
* @expectedExceptionMessage All transitions for a place must have an unique name. Multiple transitions named "t1" where found for place "a" in workflow "foo".
@ -51,20 +30,6 @@ class WorkflowValidatorTest extends TestCase
(new WorkflowValidator())->validate($definition, 'foo');
}
/**
* @expectedException \Symfony\Component\Workflow\Exception\InvalidDefinitionException
* @expectedExceptionMessage The marking store of workflow "foo" can not store many places. But the definition has 2 initial places. Only one is supported.
*/
public function testWithTooManyInitialPlaces()
{
$places = range('a', 'c');
$transitions = [];
$definition = new Definition($places, $transitions, ['a', 'b']);
(new WorkflowValidator(true))->validate($definition, 'foo');
}
public function testSameTransitionNameButNotSamePlace()
{
$places = range('a', 'd');

View File

@ -12,7 +12,6 @@ use Symfony\Component\Workflow\Exception\NotEnabledTransitionException;
use Symfony\Component\Workflow\Marking;
use Symfony\Component\Workflow\MarkingStore\MarkingStoreInterface;
use Symfony\Component\Workflow\MarkingStore\MethodMarkingStore;
use Symfony\Component\Workflow\MarkingStore\MultipleStateMarkingStore;
use Symfony\Component\Workflow\Transition;
use Symfony\Component\Workflow\TransitionBlocker;
use Symfony\Component\Workflow\Workflow;
@ -40,7 +39,7 @@ class WorkflowTest extends TestCase
public function testGetMarkingWithEmptyDefinition()
{
$subject = new Subject();
$workflow = new Workflow(new Definition([], []), new MultipleStateMarkingStore());
$workflow = new Workflow(new Definition([], []), new MethodMarkingStore());
$workflow->getMarking($subject);
}
@ -53,7 +52,7 @@ class WorkflowTest extends TestCase
{
$subject = new Subject();
$subject->setMarking(['nope' => 1]);
$workflow = new Workflow(new Definition([], []), new MultipleStateMarkingStore());
$workflow = new Workflow(new Definition([], []), new MethodMarkingStore());
$workflow->getMarking($subject);
}
@ -62,7 +61,7 @@ class WorkflowTest extends TestCase
{
$definition = $this->createComplexWorkflowDefinition();
$subject = new Subject();
$workflow = new Workflow($definition, new MultipleStateMarkingStore());
$workflow = new Workflow($definition, new MethodMarkingStore());
$marking = $workflow->getMarking($subject);
@ -76,7 +75,7 @@ class WorkflowTest extends TestCase
$definition = $this->createComplexWorkflowDefinition();
$subject = new Subject();
$subject->setMarking(['b' => 1, 'c' => 1]);
$workflow = new Workflow($definition, new MultipleStateMarkingStore());
$workflow = new Workflow($definition, new MethodMarkingStore());
$marking = $workflow->getMarking($subject);
@ -89,7 +88,7 @@ class WorkflowTest extends TestCase
{
$definition = $this->createComplexWorkflowDefinition();
$subject = new Subject();
$workflow = new Workflow($definition, new MultipleStateMarkingStore());
$workflow = new Workflow($definition, new MethodMarkingStore());
$this->assertFalse($workflow->can($subject, 'foobar'));
}
@ -98,7 +97,7 @@ class WorkflowTest extends TestCase
{
$definition = $this->createComplexWorkflowDefinition();
$subject = new Subject();
$workflow = new Workflow($definition, new MultipleStateMarkingStore());
$workflow = new Workflow($definition, new MethodMarkingStore());
$this->assertTrue($workflow->can($subject, 't1'));
$this->assertFalse($workflow->can($subject, 't2'));
@ -129,7 +128,7 @@ class WorkflowTest extends TestCase
$eventDispatcher->addListener('workflow.workflow_name.guard.t1', function (GuardEvent $event) {
$event->setBlocked(true);
});
$workflow = new Workflow($definition, new MultipleStateMarkingStore(), $eventDispatcher, 'workflow_name');
$workflow = new Workflow($definition, new MethodMarkingStore(), $eventDispatcher, 'workflow_name');
$this->assertFalse($workflow->can($subject, 't1'));
}
@ -142,7 +141,7 @@ class WorkflowTest extends TestCase
$dispatchedEvents = [];
$eventDispatcher = new EventDispatcher();
$workflow = new Workflow($definition, new MultipleStateMarkingStore(), $eventDispatcher, 'workflow_name');
$workflow = new Workflow($definition, new MethodMarkingStore(), $eventDispatcher, 'workflow_name');
$workflow->apply($subject, 't1');
$workflow->apply($subject, 't2');
@ -161,7 +160,7 @@ class WorkflowTest extends TestCase
public function testCanWithSameNameTransition()
{
$definition = $this->createWorkflowWithSameNameTransition();
$workflow = new Workflow($definition, new MultipleStateMarkingStore());
$workflow = new Workflow($definition, new MethodMarkingStore());
$subject = new Subject();
$this->assertTrue($workflow->can($subject, 'a_to_bc'));
@ -191,7 +190,7 @@ class WorkflowTest extends TestCase
{
$definition = $this->createComplexWorkflowDefinition();
$subject = new Subject();
$workflow = new Workflow($definition, new MultipleStateMarkingStore());
$workflow = new Workflow($definition, new MethodMarkingStore());
$this->assertTrue($workflow->buildTransitionBlockerList($subject, 't1')->isEmpty());
$this->assertFalse($workflow->buildTransitionBlockerList($subject, 't2')->isEmpty());
@ -216,7 +215,7 @@ class WorkflowTest extends TestCase
{
$definition = $this->createComplexWorkflowDefinition();
$subject = new Subject();
$workflow = new Workflow($definition, new MultipleStateMarkingStore());
$workflow = new Workflow($definition, new MethodMarkingStore());
$transitionBlockerList = $workflow->buildTransitionBlockerList($subject, 't2');
$this->assertCount(1, $transitionBlockerList);
@ -230,7 +229,7 @@ class WorkflowTest extends TestCase
$definition = $this->createSimpleWorkflowDefinition();
$subject = new Subject();
$dispatcher = new EventDispatcher();
$workflow = new Workflow($definition, new MultipleStateMarkingStore(), $dispatcher);
$workflow = new Workflow($definition, new MethodMarkingStore(), $dispatcher);
$dispatcher->addListener('workflow.guard', function (GuardEvent $event) {
$event->addTransitionBlocker(new TransitionBlocker('Transition blocker 1', 'blocker_1'));
@ -264,7 +263,7 @@ class WorkflowTest extends TestCase
{
$definition = $this->createComplexWorkflowDefinition();
$subject = new Subject();
$workflow = new Workflow($definition, new MultipleStateMarkingStore());
$workflow = new Workflow($definition, new MethodMarkingStore());
$workflow->apply($subject, '404 Not Found');
}
@ -273,7 +272,7 @@ class WorkflowTest extends TestCase
{
$definition = $this->createComplexWorkflowDefinition();
$subject = new Subject();
$workflow = new Workflow($definition, new MultipleStateMarkingStore());
$workflow = new Workflow($definition, new MethodMarkingStore());
try {
$workflow->apply($subject, 't2');
@ -294,7 +293,7 @@ class WorkflowTest extends TestCase
{
$definition = $this->createComplexWorkflowDefinition();
$subject = new Subject();
$workflow = new Workflow($definition, new MultipleStateMarkingStore());
$workflow = new Workflow($definition, new MethodMarkingStore());
$marking = $workflow->apply($subject, 't1');
@ -308,7 +307,7 @@ class WorkflowTest extends TestCase
{
$subject = new Subject();
$definition = $this->createWorkflowWithSameNameTransition();
$workflow = new Workflow($definition, new MultipleStateMarkingStore());
$workflow = new Workflow($definition, new MethodMarkingStore());
$marking = $workflow->apply($subject, 'a_to_bc');
@ -346,7 +345,7 @@ class WorkflowTest extends TestCase
$transitions[] = new Transition('t', 'a', 'c');
$transitions[] = new Transition('t', 'b', 'd');
$definition = new Definition($places, $transitions);
$workflow = new Workflow($definition, new MultipleStateMarkingStore());
$workflow = new Workflow($definition, new MethodMarkingStore());
$marking = $workflow->apply($subject, 't');
@ -367,7 +366,7 @@ class WorkflowTest extends TestCase
$transitions[] = new Transition('t', 'b', 'c');
$transitions[] = new Transition('t', 'c', 'd');
$definition = new Definition($places, $transitions);
$workflow = new Workflow($definition, new MultipleStateMarkingStore());
$workflow = new Workflow($definition, new MethodMarkingStore());
$marking = $workflow->apply($subject, 't');
// We want to make sure we do not end up in "d"
@ -380,7 +379,7 @@ class WorkflowTest extends TestCase
$definition = $this->createComplexWorkflowDefinition();
$subject = new Subject();
$eventDispatcher = new EventDispatcherMock();
$workflow = new Workflow($definition, new MultipleStateMarkingStore(), $eventDispatcher, 'workflow_name');
$workflow = new Workflow($definition, new MethodMarkingStore(), $eventDispatcher, 'workflow_name');
$eventNameExpected = [
'workflow.entered',
@ -427,7 +426,7 @@ class WorkflowTest extends TestCase
$subject = new Subject();
$eventDispatcher = new EventDispatcherMock();
$workflow = new Workflow($definition, new MultipleStateMarkingStore(), $eventDispatcher, 'workflow_name');
$workflow = new Workflow($definition, new MethodMarkingStore(), $eventDispatcher, 'workflow_name');
$eventNameExpected = [
'workflow.entered',
@ -480,7 +479,7 @@ class WorkflowTest extends TestCase
$subject = new Subject();
$dispatcher = new EventDispatcher();
$name = 'workflow_name';
$workflow = new Workflow($definition, new MultipleStateMarkingStore(), $dispatcher, $name);
$workflow = new Workflow($definition, new MethodMarkingStore(), $dispatcher, $name);
$assertWorkflowName = function (Event $event) use ($name) {
$this->assertEquals($name, $event->getWorkflowName());
@ -511,7 +510,7 @@ class WorkflowTest extends TestCase
$dispatcher = new EventDispatcher();
$workflow = new Workflow($definition, new MultipleStateMarkingStore(), $dispatcher, 'test');
$workflow = new Workflow($definition, new MethodMarkingStore(), $dispatcher, 'test');
$assertInitialState = function (Event $event) {
$this->assertEquals(new Marking(['a' => 1, 'b' => 1, 'c' => 1]), $event->getMarking());
@ -545,7 +544,7 @@ class WorkflowTest extends TestCase
$eventDispatcher->addListener('workflow.workflow_name.guard.t1', function (GuardEvent $event) {
$event->setBlocked(true);
});
$workflow = new Workflow($definition, new MultipleStateMarkingStore(), $eventDispatcher, 'workflow_name');
$workflow = new Workflow($definition, new MethodMarkingStore(), $eventDispatcher, 'workflow_name');
$this->assertEmpty($workflow->getEnabledTransitions($subject));
@ -565,7 +564,7 @@ class WorkflowTest extends TestCase
{
$definition = $this->createWorkflowWithSameNameTransition();
$subject = new Subject();
$workflow = new Workflow($definition, new MultipleStateMarkingStore());
$workflow = new Workflow($definition, new MethodMarkingStore());
$transitions = $workflow->getEnabledTransitions($subject);
$this->assertCount(1, $transitions);